-
-
Notifications
You must be signed in to change notification settings - Fork 2k
/
watch.js
52 lines (46 loc) · 1.28 KB
/
watch.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
import {build, context} from 'esbuild'
import progress from "@olton/esbuild-plugin-progress";
import autoprefixer from "@olton/esbuild-plugin-autoprefixer";
import {lessLoader} from "esbuild-plugin-less";
import {replace} from "esbuild-plugin-replace";
import unlink from "@olton/esbuild-plugin-unlink";
const production = process.env.MODE === "production"
let ctx = await context({
entryPoints: ['./source/default.js'],
outfile: './lib/metro.js',
bundle: true,
minify: false,
sourcemap: true,
plugins: [
progress({
text: 'Building Metro UI...',
succeedText: 'Compiled! Watching for changes...'
}),
lessLoader(),
autoprefixer(),
replace({
'__BUILD_TIME__': new Date().toLocaleString()
})
],
})
let ctxIcons = await context({
entryPoints: ['./source/icons.js'],
outfile: './lib/icons.js',
bundle: true,
minify: production,
sourcemap: false,
plugins: [
progress({
text: 'Building Metro UI icons...',
succeedText: 'Metro UI icons built successfully in %s ms!'
}),
lessLoader(),
unlink({
files: ['./lib/icons.js']
})
],
})
await Promise.all([
await ctx.watch(),
await ctxIcons.watch(),
])