-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathbuild.js
42 lines (34 loc) · 1.08 KB
/
build.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
'use strict'
const { AsyncObject } = require('@cuties/cutie')
const { SpawnedCommand } = require('@cuties/spawn')
const { CopiedFile } = require('@cuties/fs')
class LoggedToOutput extends AsyncObject {
constructor (log) {
super(log)
}
asyncCall () {
return (log, callback) => {
callback(null, log)
}
}
}
process.env.LIGHT_MODE = process.env.LIGHT_MODE || 'false'
const minFileName = process.env.LIGHT_MODE === 'true' ? 'ehtml.light.bundle.min.js' : 'ehtml.bundle.min.js'
console.log(minFileName, typeof process.env.LIGHT_MODE)
class BuiltJSFiles {
constructor (jsMainFileName, jsMinBundleName) {
return new SpawnedCommand(
'./node_modules/.bin/esbuild',
[ jsMainFileName, '--bundle', '--minify', `--outfile=${jsMinBundleName}`, `--define:LIGHT_VERSION=${process.env.LIGHT_MODE}` ]
).after(
new CopiedFile(jsMinBundleName, `./examples/static/js/${jsMinBundleName}`).after(
new LoggedToOutput(
`build for ${jsMinBundleName} is successful`
)
)
)
}
}
new BuiltJSFiles(
'src/main.js', minFileName
).call()