При исполнении команды gulp выходит ошибка
Показать ошибкуfunction watch() {
^
SyntaxError: Identifier 'watch' has already been declared
at new Script (vm.js:80:7)
at createScript (vm.js:274:10)
at Object.runInThisContext (vm.js:326:10)
at Module._compile (internal/modules/cjs/loader.js:664:28)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:712:10)
at Module.load (internal/modules/cjs/loader.js:600:32)
at tryModuleLoad (internal/modules/cjs/loader.js:539:12)
at Function.Module._load (internal/modules/cjs/loader.js:531:3)
at Module.require (internal/modules/cjs/loader.js:637:17)
at require (internal/modules/cjs/helpers.js:22:18)
Не могу понять в чем дело, подскажите, пожалуйста. Код ниже
const { gulp, series, parallel, src, dest, watch } = require("gulp");
const browserSync = require('browser-sync').create();
const phpMinify = require('@cedx/gulp-php-minify');
const autoprefixer = require('gulp-autoprefixer');
const uglify = require('gulp-uglify');
const less = require('gulp-less');
const minifyCSS = require('gulp-csso');
const concat = require('gulp-concat');
const del = require('del');
const dir = {
"src": {
php: './app/*.php',
html: './',
css: './app/src/less/**/*.less',
js: './app/src/js/**/*.js',
},
"dest": {
dest: './build/*',
php: './build/',
html: './',
css: './build/css/',
js: './build/js/',
}
}
function php() {
return src(dir.src.php, { read: false })
.pipe(phpMinify({ mode: 'fast' }))
.pipe(dest(dir.dest.php))
}
function css() {
return src(dir.src.css)
.pipe(less())
.pipe(autoprefixer())
.pipe(minifyCSS())
.pipe(dest(dir.dest.css))
.pipe(browserSync.stream())
}
function js() {
return src(dir.src.js, { sourcemaps: true })
.pipe(concat('app.min.js'))
.pipe(uglify())
.pipe(dest(dir.dest.js, { sourcemaps: true }))
.pipe(browserSync.stream())
}
function clean() {
return del(dir.dest.build);
}
function watch() {
browserSync.init({
server: {
baseDir: './app'
}
});
gulp.watch(dir.src.css, css)
gulp.watch(dir.src.js, js)
gulp.watch(dir.src.php).on('change', browserSync.reload);
}
exports.js = js;
exports.css = css;
exports.php = php;
exports.clean = clean;
exports.watch = watch;
exports.build = series(clean, parallel(css, js))
exports.default = series(build, watch);