-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
71 lines (53 loc) · 1.69 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
// ##########################
// IMPORTACIONES
// ##########################
const { dest, src, series, watch } = require('gulp');
// CSS
const sass = require('gulp-sass')( require('sass') );
const postcss = require('gulp-postcss');
const autoprefixer = require('autoprefixer');
const cssnano = require('cssnano');
const sourcemaps = require('gulp-sourcemaps');
// IMAGES
const imagemin = require('gulp-imagemin');
const webp = require('gulp-webp');
const avif = require('gulp-avif');
// ##########################
// GULP TASKS
// ##########################
const compile = done => {
src('./src/scss/main.scss')
.pipe( sourcemaps.init() )
.pipe( sass( { outputStyle: 'expanded' } ) )
.pipe( postcss( [ autoprefixer(), cssnano() ] ) )
.pipe( sourcemaps.write('.') )
.pipe( dest('./build/css') )
done();
}
const attention = () => {
watch('./src/scss/**/*.scss', compile );
}
const images = () => {
return src('./src/img/**/*')
.pipe( imagemin( { optimizationLevel: 3 } ) )
.pipe( dest('./build/img') );
}
const imageWebp = () => {
return src('./src/img/**/*.{jpg,jpeg,png}')
.pipe( webp( { quality: 50 } ) )
.pipe( dest('./build/img') )
}
const imageAvif = () => {
return src('./src/img/**/*.{jpg,jpeg,png}')
.pipe( avif( { quality: 50 } ) )
.pipe( dest('./build/img') )
}
// ##########################
// EXPORT TASKS
// ##########################
exports.compile = compile;
exports.attention = attention;
exports.images = images;
exports.imageWebp = imageWebp;
exports.imageAvif = imageAvif;
exports.default = series( compile, attention );