-
Notifications
You must be signed in to change notification settings - Fork 43
/
gulpfile.js
69 lines (61 loc) · 1.78 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
67
68
69
const gulp = require('gulp')
const rollup = require('rollup')
const ts = require('gulp-typescript');
const rename = require("gulp-rename");
const uglify = require('gulp-uglify-es').default;
const tsProject = ts.createProject('tsconfig.json', { declaration: true });
const dts = require('dts-bundle')
const onwarn = warning => {
// Silence circular dependency warning for moment package
if (warning.code === 'CIRCULAR_DEPENDENCY')
return
console.warn(`(!) ${warning.message}`)
}
gulp.task('buildJs', () => {
return tsProject.src().pipe(tsProject()).pipe(gulp.dest('./build'));
})
gulp.task("rollup", async function () {
const subTask = await rollup.rollup({
input: "build/FairyGUI.js",
external: ['three'],
onwarn: onwarn,
});
await subTask.write({
file: 'dist/fairygui.js',
format: 'umd',
extend: true,
name: 'fgui',
sourcemap: true,
globals: { three: 'three' }
});
const subTask2 = await rollup.rollup({
input: "build/FairyGUI.js",
external: ['three'],
});
await subTask2.write({
file: 'dist/fairygui.module.js',
format: 'esm',
extend: true,
name: 'fgui',
sourcemap: true,
globals: { three: 'three' }
});
});
gulp.task("uglify", function () {
return gulp.src("dist/fairygui.js")
.pipe(rename({ suffix: '.min' }))
.pipe(uglify(/* options */))
.pipe(gulp.dest("dist/"));
});
gulp.task('buildDts', function () {
return new Promise(function (resolve, reject) {
dts.bundle({ name: "fairygui-three", main: "./build/FairyGUI.d.ts", out: "../dist/fairygui.d.ts" });
resolve();
});
});
gulp.task('build', gulp.series(
'buildJs',
'rollup',
'uglify',
'buildDts'
));