-
Notifications
You must be signed in to change notification settings - Fork 5
/
build.js
40 lines (26 loc) · 921 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
const fs = require('fs');
const Terser = require('terser');
//*****************************************************************************
const src = 'src';
const dist = 'dist';
const code = [
`${src}/Color.debug.js`,
`${src}/index.js`,
`${src}/FeatureLayer.js`,
`${src}/ShadowLayer.js`
];
//*****************************************************************************
function joinFiles (files) {
if (!files.push) {
files = [files];
}
return files.map(file => fs.readFileSync(file)).join('\n');
}
//*****************************************************************************
if (!fs.existsSync(dist)) {
fs.mkdirSync(dist);
}
const js = joinFiles( code.filter(item => /\.js$/.test(item)) );
fs.writeFileSync(`${dist}/L.Line3.js`, Terser.minify(js).code);
fs.writeFileSync(`${dist}/L.Line3.debug.js`, js);
fs.writeFileSync(`${dist}/index.html`, fs.readFileSync(`${src}/index.html`));