-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
90 lines (79 loc) · 2.38 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
var gulp = require('gulp'),
sass = require('gulp-sass'),
cssnano = require('gulp-cssnano'),
browserSync = require('browser-sync'),
rename = require('gulp-rename'),
del = require('del'),
autoprefixer = require('gulp-autoprefixer'),
babel = require('gulp-babel'),
uglify = require('gulp-uglify'),
pugCompile = require('gulp-pug'),
image = require('gulp-image');
gulp.task('image', function (done) {
gulp.src('./src/img/**/*')
.pipe(image())
.pipe(gulp.dest('./dist/img'));
done()
});
sass.compiler = require('node-sass');
gulp.task('clean', async function (done) {
del.sync('dist');
done()
});
gulp.task('pug', function (done) {
return gulp.src('src/*.pug')
.pipe(pugCompile())
.pipe(gulp.dest('dist'))
.pipe(browserSync.reload({stream: true}));
done()
});
gulp.task('css', function (done) {
return gulp.src('src/scss/**/*.css')
.pipe(cssnano())
.pipe(autoprefixer({
overrideBrowserslist: ['last 2 versions'],
cascade: false
}))
.pipe(rename({suffix: '.min'}))
.pipe(gulp.dest('dist/css'))
.pipe(browserSync.reload({stream: true}));
done()
});
gulp.task('sass', function (done) {
return gulp.src('src/scss/**/*.sass')
.pipe(sass())
.pipe(cssnano())
.pipe(autoprefixer({
overrideBrowserslist: ['last 2 versions'],
cascade: false
}))
.pipe(rename({suffix: '.min'}))
.pipe(gulp.dest('dist/css'))
.pipe(browserSync.reload({stream: true}));
done()
});
gulp.task('javascript', function (done) {
return gulp.src('src/js/**/*.js')
.pipe(babel({
presets: ['@babel/env']
}))
.pipe(rename({suffix: '.min'}))
.pipe(uglify())
.pipe(gulp.dest('dist/js'))
.pipe(browserSync.reload({stream: true}));
done()
});
gulp.task('browser-sync', function () {
browserSync.init({
server: {
baseDir: "dist/"
}
});
});
gulp.task('watch', function () {
gulp.watch('src/*.pug', gulp.parallel('pug'));
gulp.watch('src/scss/*.sass', gulp.parallel('sass'));
gulp.watch('src/js/*.js', gulp.parallel('javascript'))
});
gulp.task('build', gulp.series('clean', 'pug', 'sass', 'javascript'));
gulp.task('default', gulp.parallel('pug', 'sass', 'javascript', 'browser-sync', 'watch'));