-
Notifications
You must be signed in to change notification settings - Fork 16
/
build.js
67 lines (62 loc) · 1.81 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
const { build } = require('esbuild');
const { nodeBuiltIns } = require('esbuild-node-builtins');
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({
plugins: [nodeBuiltIns()],
entryPoints: ['./browser.ts'],
minify: false,
bundle: true,
platform: 'browser',
target: ['es2020','chrome58','firefox57','safari11'],
outfile: './dist/community.js',
sourcemap: 'inline',
define: {
'process.env.NODE_DEBUG': false,
'process.env.NODE_ENV': 'production',
'process.env.DEBUG': false,
'global': 'window',
'process.cwd': 'String',
'_smartweave_1.LoggerFactory.INST': '{"create": "function() {}"}',
'_warp_1.LoggerFactory.INST': '{"create": "function() {}"}',
'__filename': 'String',
}
}).catch((e) => {
console.log(e);
process.exit(1)
});
// Minified version
build({
plugins: [nodeBuiltIns()],
entryPoints: ['./browser.ts'],
minify: true,
bundle: true,
platform: 'browser',
target: ['es2020','chrome58','firefox57','safari11'],
outfile: './dist/community.min.js',
sourcemap: 'inline',
define: {
'process.env.NODE_DEBUG': false,
'process.env.NODE_ENV': 'production',
'process.env.DEBUG': false,
'global': 'window',
'process.cwd': 'String',
'_smartweave_1.LoggerFactory.INST': '{"create": "function() {}"}',
'_warp_1.LoggerFactory.INST': '{"create": "function() {}"}',
'__filename': 'String',
}
}).catch((e) => {
console.log(e);
process.exit(1)
});
};
runBuild(true);
module.exports = runBuild;