forked from rogueg/zen
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.js
49 lines (44 loc) · 1.23 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
43
44
45
46
47
48
49
const esbuild = require('esbuild')
const yargs = require('yargs')
const { nodeExternalsPlugin } = require('esbuild-node-externals')
const argv = yargs(process.argv)
.alias('w', 'watch')
.describe('w', 'toggle watch mode').argv
let watch
if (argv.watch) {
watch = {
onRebuild(error, result) {
if (error) console.error('watch build failed:', error)
else console.log('watch build succeeded:', result)
},
}
}
// // Build the CLI
esbuild
.build({
entryPoints: ['lib/cli.ts'],
outfile: 'build/cli.js',
bundle: true,
platform: 'node',
plugins: [nodeExternalsPlugin()],
watch,
external: ['chrome-aws-lambda', 'puppeteer-core'],
})
.catch(() => process.exit(1))
function buildSimpleFile(file, outfile, platform = 'browser') {
esbuild
.build({
entryPoints: [file],
outfile: `build/${outfile}.js`,
platform,
bundle: true,
plugins: [nodeExternalsPlugin()],
external: ['chrome-aws-lambda', 'puppeteer-core'],
watch,
})
.catch(() => process.exit(1))
}
buildSimpleFile('lib/webpack/webpack-client.ts', 'webpack-client', 'node')
buildSimpleFile('lib/latte.ts', 'latte')
buildSimpleFile('lib/worker.js', 'worker')
buildSimpleFile('lib/head.js', 'head')