-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
75 lines (67 loc) · 1.79 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
const { src, dest, watch, parallel, series } = require('gulp');
const sass = require('gulp-sass')(require('sass'));
const concat = require('gulp-concat');
const browserSync = require('browser-sync').create();
const uglify = require('gulp-uglify-es').default;
const autoprefixer = require('gulp-autoprefixer');
const imagemin = require('gulp-imagemin');
const del = require('del');
function browsersync() {
browserSync.init({
server: {
baseDir: 'app/',
},
});
}
function cleanDist() {
return del('dist');
}
function images() {
return src('app/images/**/*')
.pipe(
imagemin([
imagemin.gifsicle({ interlaced: true }),
imagemin.mozjpeg({ quality: 75, progressive: true }),
imagemin.optipng({ optimizationLevel: 5 }),
imagemin.svgo({
plugins: [{ removeViewBox: true }, { cleanupIDs: false }],
}),
])
)
.pipe(dest('dist/images'));
}
function styles() {
return src('app/sass/style.sass')
.pipe(sass({ outputStyle: 'expanded' }))
.pipe(
autoprefixer({
overrideBrowserslist: ['last 10 version'],
grid: true,
})
)
.pipe(dest('app/css'))
.pipe(browserSync.stream());
}
function build() {
return src(
[
'app/css/style.css',
'app/fonts/**/*',
'app/js/main.js',
'app/*.html',
],
{ base: 'app' }
).pipe(dest('dist'));
}
function watching() {
watch(['app/sass/**/*.sass'], styles);
watch(['app/js/**/*.js']).on('change', browserSync.reload);
watch(['app/*.html']).on('change', browserSync.reload);
}
exports.styles = styles;
exports.watching = watching;
exports.browsersync = browsersync;
exports.images = images;
exports.cleanDist = cleanDist;
exports.build = series(cleanDist, images, build);
exports.default = parallel(styles, browsersync, watching);