-
-
Notifications
You must be signed in to change notification settings - Fork 2k
/
Copy pathwatch.js
70 lines (64 loc) · 2.58 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
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";
import pkg from "./package.json" with {type: "json"};
const production = process.env.MODE === "production"
const banner = `
/*!
███╗ ███╗███████╗████████╗██████╗ ██████╗ ██╗ ██╗██╗
████╗ ████║██╔════╝╚══██╔══╝██╔══██╗██╔═══██╗ ██║ ██║██║
██╔████╔██║█████╗ ██║ ██████╔╝██║ ██║ ██║ ██║██║
██║╚██╔╝██║██╔══╝ ██║ ██╔══██╗██║ ██║ ██║ ██║██║
██║ ╚═╝ ██║███████╗ ██║ ██║ ██║╚██████╔╝ ╚██████╔╝██║
╚═╝ ╚═╝╚══════╝ ╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚═════╝ ╚═╝
* Metro UI v${pkg.version} Components Library (https://metroui.org.ua)
* Copyright 2012-${new Date().getFullYear()} by Serhii Pimenov
* Licensed under MIT
*/
`
let ctx = await context({
entryPoints: ['./source/default.js'],
outfile: './lib/metro.js',
bundle: true,
minify: false,
sourcemap: true,
banner: {
js: banner
},
plugins: [
progress({
text: 'Building Metro UI...',
succeedText: 'Library compiled in %s ms! Watching for changes...'
}),
lessLoader(),
autoprefixer(),
replace({
'__BUILD_TIME__': new Date().toLocaleString(),
'__VERSION__': pkg.version,
})
],
})
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: 'Icons compiled in %s ms! Watching for changes...'
}),
lessLoader(),
unlink({
files: ['./lib/icons.js']
})
],
})
await Promise.all([
await ctx.watch(),
await ctxIcons.watch(),
])