-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
63 lines (56 loc) · 1.36 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
import gulp from 'gulp';
import browserify from 'browserify';
import source from 'vinyl-source-stream';
import babel from 'gulp-babel';
import uglify from 'gulp-uglify';
import { deleteAsync } from 'del';
import eslint from 'gulp-eslint';
import rename from 'gulp-rename';
import glob from 'glob';
const prodmode = () => {
process.env.NODE_ENV = 'production';
return;
}
const browserifytask = () => {
prodmode();
var files = glob.sync("build/**/*.js");
return browserify({ entries: files })
.bundle()
.pipe(source('main.js'))
.pipe(gulp.dest('./dist/'));
};
const lastMinify = () => {
return gulp.src('./dist/main.js')
.pipe(uglify())
.pipe(rename('main.min.js'))
.pipe(gulp.dest('./dist'));
}
const buildtask = () => {
return gulp.src([
'src/**/*.ts', 'src/*.ts'
])
.pipe(babel())
.pipe(gulp.dest('build'));
};
const cleantask = () => {
return deleteAsync([
'build/**/*', 'build/*', 'build', 'dist/*', 'dist'
]);
}
const eslintTask = () => {
return gulp.src('./src/**/*.ts')
.pipe(eslint())
.pipe(eslint.format())
.pipe(eslint.failAfterError());
}
export default gulp.series(
cleantask,
gulp.parallel(
eslintTask,
gulp.series(
buildtask,
browserifytask,
lastMinify
)
)
);