-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
67 lines (62 loc) · 1.59 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
const { src, dest, watch, series } = require('gulp');
const sass = require('gulp-sass');
const autoprefixer = require('gulp-autoprefixer');
const sourcemaps = require('gulp-sourcemaps');
const cleancss = require('gulp-clean-css');
const rename = require('gulp-rename');
const uglify = require('gulp-uglify');
const imagemin = require('gulp-imagemin');
const mozjpeg = require('imagemin-mozjpeg');
const pngquant = require('imagemin-pngquant');
const compileSass = () => {
return src('./src/css/scss/style.scss')
.pipe(sourcemaps.init())
.pipe(
sass({
outputStyle: 'expanded',
}),
)
.pipe(
autoprefixer({
overrideBrowserslist: ['defaults', 'last 2 versions'],
cascade: false,
}),
)
.pipe(sourcemaps.write('.'))
.pipe(dest('./src/css'));
};
const cssMin = () => {
return src('./src/css/style.css')
.pipe(cleancss())
.pipe(
rename({
suffix: '.min',
}),
)
.pipe(dest('./assets/css'));
};
const jsMin = () => {
return src('./src/js/*.js')
.pipe(uglify())
.pipe(
rename({
suffix: '.min',
}),
)
.pipe(dest('./assets/js'));
};
const imageMin = () => {
return src('./src/images/*.{jpg,jpeg,png,gif,svg}')
.pipe(
imagemin([
pngquant('65-80'),
mozjpeg({ quality: 80 }),
imagemin.svgo(),
imagemin.gifsicle(),
]),
)
.pipe(dest('./assets/images/'));
};
const watchSassFiles = () => watch('./src/css/scss/style.scss', compileSass);
exports.default = watchSassFiles;
exports.build = series(compileSass, cssMin, jsMin, imageMin);