-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
64 lines (61 loc) · 1.53 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
var gulp = require('gulp');
var plumber = require('gulp-plumber');
var rename = require('gulp-rename');
var cleanCss = require('gulp-clean-css');
var uglify = require('gulp-uglify');
var concat = require('gulp-concat');
var minifyHtml = require('gulp-minify-html');
gulp.task('css', function (done) {
gulp.src(['src/css/**/*.css'])
.pipe(plumber({
handleError: function (err) {
console.log(err);
this.emit('end');
}
}))
.pipe(concat('style.css'))
.pipe(gulp.dest('build/styles'))
.pipe(rename({
suffix: '.min'
}))
.pipe(cleanCss())
.pipe(gulp.dest('build/styles'))
done();
});
gulp.task('js', function (done) {
gulp.src(['src/js/**/*.js'])
.pipe(plumber({
handleError: function (err) {
console.log(err);
this.emit('end');
}
}))
.pipe(concat('script.js'))
.pipe(gulp.dest('build/scripts'))
.pipe(rename({
suffix: '.min'
}))
.pipe(uglify())
.pipe(gulp.dest('build/scripts'));
done();
});
gulp.task('html', function (done) {
gulp.src('src/index.html')
.pipe(plumber({
handleError: function (err) {
console.log(err);
this.emit('end');
}
}))
.pipe(minifyHtml())
.pipe(gulp.dest('.'));
done();
});
gulp.task('watch', function () {
gulp.watch('src/js/**/*.js', gulp.series('js'));
gulp.watch('src/css/**/*.css', gulp.series('css'));
gulp.watch('src/index.html', gulp.series('html'));
});
gulp.task('deploy', gulp.series('js', 'css', 'html', function (done) {
done();
}));