-
Notifications
You must be signed in to change notification settings - Fork 195
/
gobblefile.js
135 lines (112 loc) · 3.26 KB
/
gobblefile.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
var gobble = require('gobble');
var src = gobble('src');
// Run rollup on the web worker code, in order to include GeoJSON-vt and TopoJSON into it.
var concatenatedWebWorker = src.transform('rollup', {
entry: 'slicerWebWorker.js',
dest: 'slicerWebWorker.js.worker',
format: 'cjs',
sourceMap: true,
plugins: [
require('rollup-plugin-buble')({
include: '**/**.js'
}),
require('rollup-plugin-node-resolve')({
jsnext: false,
main: true
}),
require('rollup-plugin-commonjs')(),
// require('rollup-plugin-file-as-blob')({
// include: '**/**.png'
// }),
]
});
var uglifiedWebWorker = src.transform('rollup', {
entry: 'slicerWebWorker.js',
dest: 'slicerWebWorker.js.worker',
format: 'cjs',
sourceMap: false,
plugins: [
require('rollup-plugin-buble')({
include: '**/**.js'
}),
require('rollup-plugin-node-resolve')({
jsnext: false,
main: true
}),
require('rollup-plugin-commonjs')(),
require('rollup-plugin-uglify')()
]
});
// Get the rolled-up worker code back next to the same directory as the main code
var src2 = gobble([src, concatenatedWebWorker]);
var src2uglified = gobble([src, uglifiedWebWorker]);
// We'll run rollup four times, with slightly different options and using different
// source files (uglified worker or not). But the plugins stay the same.
var rollupPluginOptions = [
require('rollup-plugin-file-as-blob')({
// Note the '.*' at the beginning of the minimatch, because
// https://github.com/rollup/rollup-pluginutils/issues/9
include: '.*/**/**.worker'
}),
require('rollup-plugin-buble')({
include: '**/**.js'
}),
require('rollup-plugin-node-resolve')({
jsnext: false,
main: true
}),
require('rollup-plugin-commonjs')(),
];
var rollupUglyPluginOptions = rollupPluginOptions.concat([require('rollup-plugin-uglify')()]);
// Roll up the main code, merging the web worker code as a blob URL.
var builtCode = src2.transform('rollup', {
entry: 'bundle.js',
dest: 'Leaflet.VectorGrid.js',
format: 'cjs',
sourceMap: true,
plugins: rollupPluginOptions
});
// Roll up the main code plus the optional bundled deps, merging the web worker code as a blob URL.
var bundledCode = src2.transform('rollup', {
entry: 'bundle-extra.js',
dest: 'Leaflet.VectorGrid.bundled.js',
format: 'iife',
sourceMap: true,
plugins: rollupPluginOptions,
globals: {
Pbf: 'Pbf',
VectorTile: 'vector-tile',
}
});
var uglifiedCode = src2uglified.transform('rollup', {
entry: 'bundle.js',
dest: 'Leaflet.VectorGrid.min.js',
format: 'cjs',
sourceMap: false,
plugins: rollupUglyPluginOptions
});
var uglifiedBundledCode = src2uglified.transform('rollup', {
entry: 'bundle-extra.js',
dest: 'Leaflet.VectorGrid.bundled.min.js',
format: 'cjs',
sourceMap: false,
plugins: rollupUglyPluginOptions
});
var leafdoc = src.transform('leafdoc', {
templateDir: 'leafdoc-templates',
output: 'vectorgrid-api-docs.html',
showInheritancesWhenEmpty: true,
});
// var leaflet = vendor.include([
// 'leaflet-src.js',
// 'leaflet-src.map',
// 'leaflet.css'
// ]).moveTo('demo');
module.exports = gobble([
builtCode, // No extra deps, no minified
bundledCode, // Extra deps, no minified
uglifiedCode, // No extra deps, minified
uglifiedBundledCode, // Extra deps, minified
// leaflet
leafdoc
]);