| import shell from 'shelljs' | import shell from 'shelljs' | ||||
| import chalk from 'chalk' | import chalk from 'chalk' | ||||
| const cesium_path = './node_modules/cesium/build/Cesium' | |||||
| const cesium_path = path.resolve('./node_modules/cesium/build/Cesium') | |||||
| const packageJson = fse.readJsonSync('./package.json') | const packageJson = fse.readJsonSync('./package.json') | ||||
| * @returns {Promise<void>} | * @returns {Promise<void>} | ||||
| */ | */ | ||||
| async function deleteTempFile() { | async function deleteTempFile() { | ||||
| await gulp.src(['dist/modules-iife.js'], { read: false }).pipe(clean()) | |||||
| await gulp | |||||
| .src([path.join('dist', 'modules-iife.js')], { read: false }) | |||||
| .pipe(clean()) | |||||
| } | } | ||||
| async function combineJs(options) { | async function combineJs(options) { | ||||
| if (options.iife) { | if (options.iife) { | ||||
| await fse.ensureFile(path.join(cesium_path, 'Cesium.js')) | await fse.ensureFile(path.join(cesium_path, 'Cesium.js')) | ||||
| await gulp | await gulp | ||||
| .src([path.join(cesium_path, 'Cesium.js'), 'dist/modules-iife.js']) | |||||
| .src([ | |||||
| path.join(cesium_path, 'Cesium.js'), | |||||
| path.join('dist', 'modules-iife.js'), | |||||
| ]) | |||||
| .pipe(concat('dc.min.js')) | .pipe(concat('dc.min.js')) | ||||
| .pipe(gulp.dest('dist')) | .pipe(gulp.dest('dist')) | ||||
| .on('end', () => { | .on('end', () => { | ||||
| // combine for node | // combine for node | ||||
| if (options.node) { | if (options.node) { | ||||
| await gulp | await gulp | ||||
| .src('dist/index.js') | |||||
| .src(path.join('dist', 'index.js')) | |||||
| .pipe(gulp.dest('dist')) | .pipe(gulp.dest('dist')) | ||||
| .on('end', () => { | .on('end', () => { | ||||
| addCopyright(options) | addCopyright(options) | ||||
| } | } | ||||
| async function copyAssets() { | async function copyAssets() { | ||||
| await fse.emptyDir('dist/resources') | |||||
| await fse.emptyDir(path.join('dist', 'resources')) | |||||
| for (const dir of ['Assets', 'ThirdParty', 'Workers']) { | for (const dir of ['Assets', 'ThirdParty', 'Workers']) { | ||||
| await gulp | await gulp | ||||
| .src(path.join(cesium_path, dir, '**'), { nodir: true }) | .src(path.join(cesium_path, dir, '**'), { nodir: true }) | ||||
| .pipe(gulp.dest(path.join('dist/resources', dir))) | |||||
| .pipe(gulp.dest(path.join('dist', 'resources', dir))) | |||||
| } | } | ||||
| } | } | ||||
| async function regenerate(option) { | async function regenerate(option) { | ||||
| await fse.remove('dist/dc.min.js') | |||||
| await fse.remove('dist/dc.min.css') | |||||
| await fse.remove(path.join('dist', 'dc.min.js')) | |||||
| await fse.remove(path.join('dist', 'dc.min.css')) | |||||
| await buildModules(option) | await buildModules(option) | ||||
| await combineJs(option) | await combineJs(option) | ||||
| await buildCSS(option) | await buildCSS(option) |