"use strict";
const {src, dest, parallel, watch} = pkg;
import pkg from 'gulp';
import pug from 'gulp-pug';
import plumber from 'gulp-plumber';
import server from 'browser-sync';
import sass from 'gulp-dart-sass';
import autoPrefixer from 'gulp-autoprefixer';
import concat from 'gulp-concat';
import imagemin from 'imagemin';
import webp from 'gulp-webp';
import newer from 'gulp-newer';
import minify from 'gulp-jsmin';
import sourcemaps from 'gulp-sourcemaps';
const pugfiles = () =>{
return src('src/*.pug')
.pipe(plumber())
.pipe(pug({
pretty: true
}))
.pipe(dest('./dist'))
};
const serve = () =>{
server.init({
server: {baseDir: './dist'},
notify: false,
online: true
})
};
const styles = () =>{
return src('src/scss/*.scss')
.pipe(sourcemaps.init())
.pipe(sass({
outputStyle: 'compressed'
}).on('error' , sass.logError))
.pipe(autoPrefixer())
.pipe(concat('style.min.css'))
.pipe(sourcemaps.write('../maps'))
.pipe(dest('dist/css'))
};
const scripts = () =>{
return src('src/js/*.js')
.pipe(plumber())
.pipe(concat('app.min.js'))
.pipe(minify())
.pipe(dest('dist/js'))
};
const images = () =>{
return src('src/images/**/*')
.pipe(newer('dist/images/'))
.pipe(imagemin())
.pipe(webp())
.pipe(dest('dist/images'))
}
const watcher = () =>{
watch('src/**/*.pug', pugfiles).on('change', server.reload);
watch('src/**/*.scss', styles).on('change', server.reload);
watch(['src/js/**/*.js', '!src/js/**/*.min.js'], scripts).on('change', server.reload);
watch('src/images/**/*', images);
};
export default parallel(
pugfiles,
serve,
watcher,
styles,
scripts,
images
);
Выдаёт ошибку :
PS E:\projects\git\test-gulp> gulp
[00:14:18] Using gulpfile E:\projects\git\test-gulp\gulpfile.js
[00:14:18] Starting 'default'...
[00:14:18] Starting 'pugfiles'...
[00:14:18] Starting 'serve'...
[00:14:18] Starting 'watcher'...
[00:14:18] Starting 'styles'...
[00:14:18] Starting 'scripts'...
[00:14:18] Starting 'images'...
[00:14:19] 'images' errored after 106 ms
[00:14:19] TypeError: dest.on is not a function
at Newer.Readable.pipe (internal/streams/readable.js:652:8)
at images (file:///E:/projects/git/test-gulp/gulpfile.js:59:6)
at bound (domain.js:416:15)
at runBound (domain.js:427:12)
at asyncRunner (E:\projects\git\test-gulp\node_modules\async-done\index.js:55:18)
at processTicksAndRejections (internal/process/task_queues.js:77:11)
[00:14:19] 'default' errored after 114 ms