-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathesbuild.js
68 lines (61 loc) · 1.76 KB
/
esbuild.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import * as esbuild from 'esbuild'
import autoprefixer from "autoprefixer";
import postcss from "postcss";
import {sassPlugin} from 'esbuild-sass-plugin'
// Use --watch flag to watch for changes and rebuild automatically.
const isWatch = process.argv.slice(2).includes('--watch');
let cssStartTime;
const watchPlugin = {
name: 'watch-plugin',
setup(build) {
build.onStart(() => {
cssStartTime = Date.now();
});
build.onEnd((result) => {
if (result.errors.length) {
console.log(result.errors);
}
console.log(`Compiled styles with esbuild (${esbuild.version}) in ${Date.now() - cssStartTime}ms`);
});
}
};
let context = await esbuild.context({
entryPoints: [
{
in: 'src/assets/admin/scss/admin.scss',
out: 'src/assets/admin/css/admin.min'
},
{
in: 'src/assets/admin/scss/tinymce.scss',
out: 'src/assets/admin/css/tinymce.min'
},
{
in: 'src/assets/admin/js/admin.js',
out: 'src/assets/admin/js/admin.min'
},
{
in: 'src/assets/fontawesome/css/all.css',
out: 'src/assets/fontawesome/css/all.min'
},
{
in: 'src/assets/signup/js/signup.js',
out: 'src/assets/signup/js/signup.min'
},
],
minify: true,
outdir: './',
plugins: [watchPlugin, sassPlugin({
async transform(source) {
const {css} = await postcss([autoprefixer]).process(source, {from: undefined});
return css;
}
})],
sourcemap: true,
target: 'es5',
})
if (isWatch) {
await context.watch();
} else {
await context.rebuild();
await context.dispose();
}