-
Notifications
You must be signed in to change notification settings - Fork 9
/
gulpfile.js
70 lines (63 loc) · 1.54 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
70
const gulp = require('gulp');
const uglify = require('gulp-uglify');
const csso = require('gulp-csso');
const exec = require('child_process').exec;
// Element build
gulp.task('element-build', callback => {
exec('mkdir -p dist/assets && node build/build.js',
function(err, stdout, stderr) {
if (stdout) {
console.log(stdout);
}
if (stderr) {
console.log(stderr);
}
callback(err);
});
});
// Copy images
gulp.task('image', () => {
return gulp.src(['img/!(TableHero.png)']).pipe(gulp.dest('dist/img'));
});
// Copy assets
gulp.task('assets', () => {
return gulp.src('assets/*').pipe(gulp.dest('dist/assets'));
});
// Minify files
gulp.task('minify-js', () => {
return gulp
.src('assets/*.js')
.pipe(uglify())
.pipe(gulp.dest('dist/assets'));
});
gulp.task('minify-css', () => {
return gulp
.src('assets/*.css')
.pipe(csso())
.pipe(gulp.dest('dist/assets'));
});
// Default build
gulp.task(
'default',
gulp.series([
'element-build',
'assets',
gulp.parallel(['image', 'minify-js', 'minify-css'])
])
);
// Watch when in development
gulp.task('watch', gulp.parallel(function watch () {
gulp.watch('assets/*', gulp.parallel('assets'));
gulp.watch('img/*', gulp.parallel('image'));
gulp.watch('build/*', gulp.parallel('element-build'));
}));
// Development
gulp.task(
'dev',
gulp.series([
'element-build',
'assets',
'image',
'watch'
])
);