-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathgulpfile.js
62 lines (55 loc) · 1.51 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
/**
@author : Caven Chen
**/
'use strict'
import fse from 'fs-extra'
import path from 'path'
import gulp from 'gulp'
import esbuild from 'esbuild'
const buildConfig = {
bundle: true,
color: true,
legalComments: `inline`,
logLimit: 0,
target: `es2019`,
minify: true,
sourcemap: false,
write: true,
logLevel: 'info',
external: [`http`, `https`, `url`, `zlib`],
plugins: [],
}
async function buildNamespace(options) {
await esbuild.build({
...buildConfig,
entryPoints: ['src/index.js'],
format: options.node ? 'esm' : 'iife',
globalName: 'DC_Common',
external: options.node
? [...buildConfig.external, '@cesium/engine']
: [...buildConfig.external],
outfile: path.join('dist', options.node ? 'index.js' : 'dc.common.min.js'),
})
}
async function copyAssets() {
await fse.emptyDir('dist/resources')
await gulp
.src('./node_modules/@cesium/engine/Build/Workers/**', { nodir: true })
.pipe(gulp.dest('dist/resources/Workers'))
await gulp
.src('./node_modules/@cesium/engine/Source/Assets/**', { nodir: true })
.pipe(gulp.dest('dist/resources/Assets'))
await gulp
.src('./node_modules/@cesium/engine/Source/ThirdParty/**', { nodir: true })
.pipe(gulp.dest('dist/resources/ThirdParty'))
}
export const build = gulp.series(
() => buildNamespace({ node: true }),
() => buildNamespace({ iife: true }),
copyAssets
)
export const buildRelease = gulp.series(
() => buildNamespace({ node: true }),
() => buildNamespace({ iife: true }),
copyAssets
)