forked from CesiumChina/cesium-map
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
66 lines (60 loc) · 1.49 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
/**
@author : Caven Chen
@date : 2023-05-15
*/
import gulp from 'gulp'
import { rollup } from 'rollup'
import commonjs from '@rollup/plugin-commonjs'
import resolve from '@rollup/plugin-node-resolve'
import { babel } from '@rollup/plugin-babel'
import terser from '@rollup/plugin-terser'
async function buildMap(options) {
const bundle = await rollup({
input: 'src/index',
external: ['cesium/Build/Cesium'],
plugins: [
commonjs(),
resolve({ preferBuiltins: true }),
babel({
babelHelpers: 'runtime',
presets: [
[
'@babel/preset-env',
{
modules: false,
targets: {
browsers: ['> 1%', 'last 2 versions', 'ie >= 10'],
},
},
],
],
plugins: ['@babel/plugin-transform-runtime'],
}),
terser(),
],
})
// Build IIFE
if (options.iife) {
await bundle.write({
file: 'dist/cesium.map.min.js',
format: 'iife',
name: 'window',
extend: true,
globals: {
'cesium/Build/Cesium': 'Cesium',
},
sourcemap: false,
})
}
// Build Node
if (options.node) {
await bundle.write({
file: 'dist/index.cjs',
format: 'cjs',
sourcemap: false,
})
}
}
export const build = gulp.series(() => buildMap({ node: true, iife: true }))
export const buildNode = gulp.series(() => buildMap({ node: true }))
export const buildIIFE = gulp.series(() => buildMap({ iife: true }))