-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
53 lines (44 loc) · 1.36 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
const {src, dest, watch, series} = require ('gulp');
// SASS
const autoprefixer = require('autoprefixer');
const cssnano= require('cssnano');
const postcss = require('gulp-postcss');
const sass = require('gulp-sass') (require('sass'));
const sourcemaps = require('gulp-sourcemaps');
// images
const avif = require('gulp-avif');
const imagemin = require('gulp-imagemin')
const webp = require('gulp-webp');
function css() {
return src('src/scss/style.scss')
.pipe(sourcemaps.init())
.pipe( sass())
.pipe( postcss([autoprefixer(),cssnano()])) //add cssnano() to minify your code if you need it
.pipe(sourcemaps.write('.'))
.pipe( dest('build/css'));
}
function images() {
return src('src/images/**/*', css)
.pipe(imagemin())
.pipe(dest('build/images'))
}
function webpVersion(){
return src('src/images/**/*.{png,jpg}')
.pipe( webp())
.pipe(dest('build/images'));
}
function avifVersion(){
return src('src/images/**/*.{png,jpg}')
.pipe( avif())
.pipe(dest('build/images'));
}
function dev() {
watch('src/scss/**/*.scss', css)
watch('src/images/**/*', images)
}
exports.avifVersion = avifVersion;
exports.css = css;
exports.images = images;
exports.dev = dev;
exports.webpVersion = webpVersion;
exports.default = series( css, webpVersion, avifVersion, images, dev)