-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
60 lines (51 loc) · 1.47 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
const { src, dest, watch, series } = require('gulp');
// CSS y SASS
const sass = require('gulp-sass')(require('sass'));
const postcss = require('gulp-postcss');
const autoprefixer = require('autoprefixer');
const sourcemaps = require('gulp-sourcemaps');
const cssnano = require('cssnano');
// Imagenes
const imagemin = require('gulp-imagemin');
const webp = require('gulp-webp');
const avif = require('gulp-avif');
function css( done ) {
src('src/scss/app.scss')
.pipe( sourcemaps.init() )
.pipe( sass() )
.pipe( postcss([ autoprefixer(), cssnano() ]) )
.pipe( sourcemaps.write('.'))
.pipe( dest('build/css') )
done();
}
function imagenes() {
return src('src/img/**/*')
.pipe( imagemin({ optimizationLevel: 3 }) )
.pipe( dest('build/img') )
}
function versionWebp() {
const opciones = {
quality: 50
}
return src('src/img/**/*.{png,jpg}')
.pipe( webp( opciones ) )
.pipe( dest('build/img') )
}
function versionAvif() {
const opciones = {
quality: 50
}
return src('src/img/**/*.{png,jpg}')
.pipe( avif( opciones ) )
.pipe( dest('build/img'))
}
function dev() {
watch( 'src/scss/**/*.scss', css );
watch( 'src/img/**/*', imagenes );
}
exports.css = css;
exports.dev = dev;
exports.imagenes = imagenes;
exports.versionWebp = versionWebp;
exports.versionAvif = versionAvif;
exports.default = series( imagenes, versionWebp, versionAvif, css, dev );