-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
54 lines (45 loc) · 1.33 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
const gulp = require('gulp');
const browserify = require('browserify');
const minify = require('gulp-minify');
const babel = require('gulp-babel');
const buffer = require('vinyl-buffer');
const source = require('vinyl-source-stream');
const del = require("del");
gulp.task("clean",() => {
return del("tmp", {force:true});
});
gulp.task('apply-prod-environment', function() {
process.env.NODE_ENV = 'production';
return Promise.resolve();
});
gulp.task("ui-babel", () => {
return gulp.src(["src/ui/**/*.jsx","src/ui/**/*.js"])
.pipe(babel({
presets: ["@babel/preset-env", "@babel/preset-react"],
plugins: ["@babel/plugin-transform-runtime"]
}))
.pipe(gulp.dest("tmp/ui/"));
});
gulp.task("browserify", () => {
return browserify({entries:"tmp/ui/ui.js",debug:false})
.bundle()
.pipe(source("ui.js"))
.pipe(buffer())
.pipe(gulp.dest("public/js"));
});
gulp.task("minify", () => {
return gulp.src('public/js/ui.js')
.pipe(minify({
ext:{
src:'.js',
min:'.min.js'
}
}))
.pipe(gulp.dest("public/js"));
});
gulp.task("ui-min", gulp.series("apply-prod-environment","ui-babel","browserify","minify","clean"));
gulp.task("ui", gulp.series("ui-babel","browserify","clean"));
gulp.task("watch", () => {
return gulp.watch(["src/ui/**/*.jsx","src/ui/**/*.js"],gulp.series("ui"));
});
gulp.task("default", gulp.series("ui"));