forked from openstreetmap/iD
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build_src.js
65 lines (58 loc) · 1.95 KB
/
build_src.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
/* eslint-disable no-console */
const colors = require('colors/safe');
const commonjs = require('rollup-plugin-commonjs');
const includePaths = require('rollup-plugin-includepaths');
const json = require('rollup-plugin-json');
const nodeResolve = require('rollup-plugin-node-resolve');
const rollup = require('rollup');
const shell = require('shelljs');
module.exports = function buildSrc() {
var isBuilding = false;
return function () {
if (isBuilding) return;
// Start clean
shell.rm('-f', [
'dist/iD.js',
'dist/iD.js.map'
]);
console.log('building src');
console.time(colors.green('src built'));
isBuilding = true;
return rollup
.rollup({
input: './modules/id.js',
plugins: [
includePaths( {
paths: ['node_modules/d3/node_modules'], // npm2 or windows
include: {
'martinez-polygon-clipping': 'node_modules/martinez-polygon-clipping/dist/martinez.umd.js'
}
}),
nodeResolve({
module: true,
main: true,
browser: false
}),
commonjs(),
json({ indent: '' })
]
})
.then(function (bundle) {
return bundle.write({
format: 'iife',
file: 'dist/iD.js',
sourcemap: true,
strict: false
});
})
.then(function () {
isBuilding = false;
console.timeEnd(colors.green('src built'));
})
.catch(function (err) {
isBuilding = false;
console.error(err);
process.exit(1);
});
};
};