-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
62 lines (53 loc) · 1.43 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
let browserSync = require('browser-sync'),
gulp = require('gulp'),
postcss = require('gulp-postcss'),
autoprefixer = require('autoprefixer'),
cssnano = require('cssnano')
sass = require('gulp-sass'),
image = require('gulp-image'),
media = require('gulp-group-css-media-queries'),
notify = require('gulp-notify'),
pug = require('gulp-pug');
gulp.task('browserSync', function () {
browserSync({
server: {
baseDir: 'assets'
},
notify: false
})
});
gulp.task('postcss', function () {
const processor = ([
autoprefixer({browsers: ['last 2 versions', 'safari 5']}),
cssnano()
]);
return gulp.src('./assets/sass/*.sass')
.pipe(sass().on("error", notify.onError()))
.pipe(media())
.pipe(postcss(processor))
.pipe(gulp.dest('./assets/css'))
.pipe(browserSync.reload({
stream: true
}))
});
gulp.task('image', function () {
return gulp.src('./assets/img/**/*')
.pipe(image())
.pipe(gulp.dest('./assets/img/'))
})
gulp.task('pug', function buildHTML() {
return gulp.src('assets/*.pug')
.pipe(pug({
pretty: true
}).on("error", notify.onError()))
.pipe(gulp.dest('assets'))
.pipe(browserSync.reload({
stream: true
}));
});
gulp.task('watch', ['postcss', 'pug', 'browserSync'], function () {
gulp.watch('assets/sass/**/*.sass', ['postcss']);
gulp.watch(['assets/*.pug', 'assets/pug/**/*.pug'], ['pug']);
gulp.watch('assets/js/**/*.js', browserSync.reload);
});
gulp.task('default', ['watch']);