-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
115 lines (106 loc) · 2.68 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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
var gulp = require('gulp'),
sass = require('gulp-sass'),
browserSync = require('browser-sync').create(),
pug = require('gulp-pug'),
plumber = require("gulp-plumber"),
postcss = require("gulp-postcss"),
autoprefixer = require("autoprefixer"),
minify = require("gulp-csso"),
rename = require("gulp-rename"),
imagemin = require("gulp-imagemin"),
del = require("del"),
run = require("run-sequence"),
jsmin = require("gulp-jsmin");
gulp.task('pug', function buildHTML() {
return gulp.src('app/pug/*.pug')
.pipe(plumber())
.pipe(pug({
pretty: true
}))
.pipe(gulp.dest('docs'))
.pipe(browserSync.reload({
stream: true
}))
});
gulp.task('sass', function(){
gulp.src('app/sass/**/*.scss')
.pipe(plumber(
// {
// errorHandler: function (err) {
// console.log(err);
// this.emit('end');
// }
// }
))
.pipe(sass({errLogToConsole: true}))
.pipe(postcss([ autoprefixer() ]))
.pipe(gulp.dest('docs/css'))
.pipe(minify())
.pipe(rename({
suffix: '.min'
}))
.pipe(gulp.dest('docs/css'))
.pipe(browserSync.reload({
stream: true
}))
});
gulp.task("jscript", function () {
gulp.src("app/js/*.js")
.pipe(plumber())
.pipe(gulp.dest('docs/js/'))
.pipe(jsmin())
.pipe(rename({suffix: ".min"}))
.pipe(gulp.dest('docs/js/'))
.pipe(browserSync.reload({stream: true}));
});
gulp.task('clean', function () {
return del('docs');
});
gulp.task('copy', function () {
return gulp.src([
'app/fonts/**/*.{woff,woff2}',
'app/libs/**/*.js'
], {
base: 'app'
})
.pipe(gulp.dest('docs'))
});
gulp.task('images', function () {
return gulp.src('app/img/**/*')
.pipe(imagemin([
imagemin.optipng({
optimizationLevel: 3
}),
imagemin.jpegtran({
progressive: true
}),
imagemin.svgo()
], {
verbose: true
}))
.pipe(gulp.dest('docs/img'))
});
gulp.task('browser-sync', function() {
browserSync.init({
server: {
baseDir: 'docs'
},
notify: false
});
});
gulp.task('watch', ['browser-sync'], function() {
gulp.watch('app/sass/**/*.scss', ['sass']);
gulp.watch('app/pug/*.pug', ['pug']);
gulp.watch('app/js/*.js', ['jscript']);
});
gulp.task('develop', function (fn) {
run(
'clean',
'copy',
'images',
'pug',
'sass',
'jscript',
fn
) ;
});