forked from xtfge/arrow-graphic
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
73 lines (68 loc) · 2.13 KB
/
gulpfile.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
68
69
70
71
72
73
const rollup = require('rollup');
const rollupPluginStripPragma = require('rollup-plugin-strip-pragma');
const babel = require('rollup-plugin-babel');
const rollupPluginUglify = require('rollup-plugin-uglify');
const uglify = require('rollup-plugin-uglify-es');
const gulp = require('gulp');
const os = require('os');
const path = require('path');
const rimraf = require('rimraf');
function rollupWarning(message) {
// Ignore eval warnings in third-party code we don't have control over
if (message.code === 'EVAL' && /(protobuf-minimal|crunch)\.js$/.test(message.loc.file)) {
return;
}
console.log(message);
}
function combineJS(debug, optimizer, filename) {
const plugins = [babel()];
if (!debug) {
plugins.push(rollupPluginStripPragma({
pragmas: ['debug'],
}));
}
if (optimizer === 'uglify2-es') {
plugins.push(uglify());
}
if (optimizer === 'uglify2') {
plugins.push(rollupPluginUglify.uglify());
}
let format = 'umd';
if (/.*es$/.test(optimizer)) {
format = 'esm';
}
const ext = /.*es$/.test(optimizer) ? '.esm.js' : '.umd.js';
return rollup.rollup({
input: 'source/ArrowGraphic.js',
plugins,
onwarn: rollupWarning,
}).then((bundle) => bundle.write({
format,
name: 'ArrowGraphic',
file: path.join('./', `${filename}${ext}`),
sourcemap: debug
}));
}
function build() {
rimraf.sync("./build");
combineJS(true, 'none', path.join('build', 'ArrowGraphic'));
combineJS(false, 'uglify2', path.join('build', 'ArrowGraphic.min'));
combineJS(true, 'none-es', path.join('build', 'ArrowGraphic'));
return combineJS(false, 'uglify2-es', path.join('build', 'ArrowGraphic.min'));
// combineJavaScript({
// removePragmas: true,
// optimizer: 'uglify2-es',
// outputDirectory: path.join('build', 'CesiumPro'),
// });
// combineJavaScript({
// removePragmas: false,
// optimizer: 'none-es',
// outputDirectory: path.join('build', 'CesiumProUnminified'),
// });
// return combineJavaScript({
// removePragmas: false,
// optimizer: 'none',
// outputDirectory: path.join('build', 'CesiumProUnminified'),
// });
}
gulp.task('build', build);