Не запускается дефолтная команда gulp.
Вот мой gulpfile.js :
const {
src,
dest,
parallel,
series,
watch
} = require('gulp');
// Load plugins
const cssnano = require('gulp-cssnano');
const changed = require('gulp-changed');
const browsersync = require('browser-sync').create();
const imagemin = import('gulp-imagemin');
const clean = require('gulp-clean');
function clear() {
return src('./build/*', {
read: false
})
.pipe(clean());
}
// CSS
function css() {
const source = './src/css/style.css';
return src(source)
.pipe(changed(source))
.pipe(cssnano())
.pipe(dest('./build/css/'))
.pipe(browsersync.stream());
}
// Optimize images
function img() {
return src('./src/images/*')
.pipe(imagemin())
.pipe(dest('./build/imeges'));
}
// html
function html() {
return src('./src/*.html')
.pipe(dest('./build/'))
.pipe(browsersync.stream())
}
// Watch files
function watchFiles() {
watch('./src/css/*', css);
watch('./src/*.html', html);
watch('./src/images/*', img);
}
// BrowserSync
function browserSync() {
browsersync.init({
server: {
baseDir: './build'
},
port: 3000
});
}
exports.watch = parallel(watchFiles, browserSync);
exports.default = series(clear, parallel(html, css, img));
А вот что выводит в ошибке (в терминале):
[09:36:44] Using gulpfile ~\Desktop\app\gulpfile.js
[09:36:44] Starting 'default'...
[09:36:44] Starting 'clear'...
[09:36:44] Finished 'clear' after 45 ms
[09:36:44] Starting 'html'...
[09:36:44] Starting 'css'...
[09:36:44] Starting 'img'...
[09:36:44] 'img' errored after 12 ms
[09:36:44] TypeError: imagemin is not a function
at img (C:\Users\Samrux\Desktop\app\gulpfile.js:42:15)
at bound (node:domain:421:15)
at runBound (node:domain:432:12)
at asyncRunner (C:\Users\Samrux\Desktop\app\node_modules\async-done\index.js:55:18)
at processTicksAndRejections (node:internal/process/task_queues:78:11)
[09:36:44] 'default' errored after 72 ms
Кстати, если вас интересует почему в начале у всех функции require, a у imagemin - import, то раньше была ошибка
'ERR_REQUIRE_ESM'
Ещё доп инфо:
"browser-sync": "^2.27.5",
"gulp": "^4.0.2",
"gulp-changed": "^4.0.3",
"gulp-clean": "^0.4.0",
"gulp-cssnano": "^2.1.3",
"gulp-imagemin": "^8.0.0"