-
-
Notifications
You must be signed in to change notification settings - Fork 109
/
gulpfile.js
57 lines (51 loc) · 1.18 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
/**
@author : Caven Chen
@date : 2023-05-15
*/
import gulp from 'gulp'
import path from 'path'
import esbuild from 'esbuild'
import GlobalsPlugin from 'esbuild-plugin-globals'
const buildConfig = {
entryPoints: ['src/index.js'],
bundle: true,
color: true,
legalComments: `inline`,
logLimit: 0,
target: `es2019`,
minify: true,
sourcemap: false,
write: true,
logLevel: 'info',
plugins: [],
external: ['@cesium/engine'],
}
async function buildMap(options) {
// Build IIFE
if (options.iife) {
await esbuild.build({
...buildConfig,
format: 'iife',
globalName: '',
plugins: [
GlobalsPlugin({
'@cesium/engine': 'Cesium',
}),
],
outfile: path.join('dist', 'cesium.map.min.js'),
})
}
// Build Node
if (options.node) {
if (options.iife) {
await esbuild.build({
...buildConfig,
format: 'esm',
outfile: path.join('dist', 'index.js'),
})
}
}
}
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 }))