const { src, dest , watch , parallel } = require('gulp');
const scss = require('gulp-sass')(require('sass'));
const concat = require('gulp-concat');
const uglify = require('gulp-uglify');
const browserSync = require('browser-sync').create();
function browsersync() {
browserSync.init({
server: {
baseDir: 'app/'
}
})
}
function styles() {
return src('./app/scss/style.scss')
.pipe(scss({outputStyle: 'compressed'}))
.pipe(concat('style.min.css'))
.pipe(dest('app/css'))
.pipe(browserSync.stream())
}
function scripts() {
return src([
'node_modules/jquery/dist/jquery.js',
'./app/js/main.js'
])
.pipe(concat('main.min.js'))
.pipe(uglify())
.pipe(dest('app/js'))
.pipe(browserSync.reload())
}
function watching() {
watch('./app/scss/**/*.scss' , styles);
watch('./app/js/**/*.js', '!app/js/main.min.js' , scripts);
watch("app/*.html").on('change', browserSync.reload);
}
exports.styles = styles;
exports.scripts = scripts;
exports.browsersync = browsersync;
exports.watching = watching;
exports.default = parallel(styles, scripts, browsersync, watching);
выдает такую ошибку:
[11:05:32] Starting 'default'...
[11:05:32] Starting 'styles'...
[11:05:32] Starting 'scripts'...
[11:05:32] Starting 'browsersync'...
[11:05:32] Starting 'watching'...
[11:05:32] 'scripts' errored after 8.49 ms
[11:05:32] TypeError: Cannot read properties of undefined (reading 'on')
at Readable.pipe (A:\gitHub project\start_gulp\node_modules\readable-stream\lib\_stream_readable.js:564:8)
at scripts (A:\gitHub project\start_gulp\gulpfile.js:32:6)
at bound (node:domain:433:15)
at runBound (node:domain:444:12)
at asyncRunner (A:\gitHub project\start_gulp\node_modules\async-done\index.js:55:18)
at process.processTicksAndRejections (node:internal/process/task_queues:77:11)
[11:05:32] 'default' errored after 11 ms