-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.js
42 lines (37 loc) · 961 Bytes
/
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
const { build } = require('esbuild');
const rimraf = require('rimraf');
const clean = async () => {
return new Promise(resolve => {
rimraf('./dist', () => resolve());
});
}
const runBuild = async (doClean = false) => {
// Do not clean each time on watch, only on build or first run.
if(doClean) await clean();
// Build to browser js
build({
entryPoints: ['./src/index.ts'],
minify: false,
bundle: true,
outfile: './dist/smartweave.js',
platform: 'browser',
target: ['es2020','chrome58','firefox57','safari11']
}).catch((e) => {
console.log(e);
process.exit(1)
});
// Minified version
build({
entryPoints: ['./src/index.ts'],
minify: true,
bundle: true,
outfile: './dist/smartweave.min.js',
platform: 'browser',
target: ['es2020','chrome58','firefox57','safari11']
}).catch((e) => {
console.log(e);
process.exit(1)
});
};
runBuild(true);
module.exports = runBuild;