#javascript #json #gulp
#javascript #json #gulp
Вопрос:
Когда я пытаюсь запустить gulp default
команду в git bash, произошла ошибка!
Ошибка утверждения [ERR_ASSERTION]: функция задачи должна быть указана в Gulp.set [как _setTask] (C:wamp64wwwWP-PROJECTSthfireplaces.cademo_newwp-contentthemesthfireplacesnode_modulesundertakerlibset-task.js:10:3 ) залпом.задание (C:wamp64wwwWP-PROJECTSthfireplaces.cademo_newwp-contentthemesthfireplacesnode_modulesundertakerlibtask.js:13:8 ) на Объекте. (C:wamp64wwwWP-PROJECTSthfireplaces.cademo_newwp-contentthemesthfireplacesgulpfile.js:181:6 ) в модуле._compile (internal/modules/cjs/loader.js:955:30) в объекте.Module._extensions..js (внутренний/modules/cjs/loader.js:991:10) в модуле.загрузка (internal/modules/cjs/loader.js:811:32) в функции.Модуль._load (internal/modules/cjs/loader.js:723:14) в Module.require (internal/modules/cjs/loader.js:848:19) в require (internal/modules/cjs/helpers.js:74:18) в requireOrImport (C:UsersMomin Эр-РиядAppDataРоуминг npm node_modulesgulp node_modulesgulp-clilib sharedrequire-or-import.js:19:11) { Генерируемое сообщение: false, код: ‘ERR_ASSERTION’, фактическое: false, ожидаемое: true, оператор: ‘==’ }
Вот сведения о моей машине версия узла версия 12.14.1
npm 7.0.2
локальная версия gulp 4.0.2
!
package.json
{
"name": "instaHtmlQuickPack",
"version": "0.6.5",
"description": "Html Quick Pack",
"main": "index.js",
"scripts": {
"postinstall": "gulp default"
},
"engines": {
"npm": ">=2.1.8"
},
"repository": {
"type": "git",
"url": "#"
},
"keywords": [
"wordpress",
"theme",
"bootstrap"
],
"author": "Azizul Hoq",
"license": "GPL-2.0",
"bugs": {
"url": "#"
},
"homepage": "#",
"dependencies": {
"bootstrap": "4.3.1",
"browser-sync": "^2.18.12",
"del": "^3.0.0",
"gulp": "^4.0.0",
"gulp-clean-css": "^3.7.0",
"gulp-clone": "^1.0.0",
"gulp-concat": "^2.6.1",
"gulp-cssnano": "^2.1.2",
"gulp-ignore": "^2.0.2",
"gulp-imagemin": "^3.3.0",
"gulp-merge": "^0.1.1",
"gulp-plumber": "^1.1.0",
"gulp-rename": "^1.2.2",
"gulp-rimraf": "^0.2.1",
"gulp-sass": "^3.1.0",
"gulp-sequence": "^0.4.6",
"gulp-sourcemaps": "2.6.0",
"gulp-uglify": "^3.0.0",
"gulp-watch": "^4.3.11",
"jquery": "3.2.1",
"merge2": "^1.1.0",
"popper.js": "^1.11.1",
"run-sequence": "^2.0.0"
},
"devDependencies": {
"gulp-autoprefixer": "^4.0.0",
"gulp-csscomb": "^3.0.8",
"gulp-filenames": "^4.0.1"
}
}
gulpfile.js
// Defining base pathes
var basePaths = {
node: './node_modules/',
src: './src/',
assets: './assets/',
vendorsCss: './src/vendors/css/',
vendorsJs: './src/vendors/js/'
};
var jsFileList = [
basePaths.vendorsJs '*.js',
basePaths.src 'js/custom-script.js'
];
var cssFileList = [
basePaths.vendorsCss '*.css'
];
// console.log(jsFileList);
// Defining requirements
var gulp = require('gulp');
var plumber = require('gulp-plumber');
var sass = require('gulp-sass');
var watch = require('gulp-watch');
var minifyCSS = require('gulp-cssnano');
var rename = require('gulp-rename');
var concat = require('gulp-concat');
var uglify = require('gulp-uglify');
var merge2 = require('merge2');
var ignore = require('gulp-ignore');
var del = require('del');
var sourcemaps = require('gulp-sourcemaps');
var autoprefixer = require('gulp-autoprefixer');
var csscomb = require('gulp-csscomb');
var imagemin = require('gulp-imagemin');
var browserSync = require('browser-sync').create();
// browser-sync watched files
// automatically reloads the page when files changed
var browserSyncWatchFiles = [
basePaths.assets 'css/*.css',
basePaths.assets 'js/*.js',
basePaths.src 'media/**',
'./*.html',
'./*.php'
];
var browserSyncOptions = {
proxy: "http://localhost/WP-PROJECTS/thfireplaces.ca/demo_new/",
notify: false
};
// Run:
// gulp browser-sync
// Starts browser-sync task for starting the server.
gulp.task('browser-sync', function() {
browserSync.init(browserSyncWatchFiles, browserSyncOptions);
});
// Run:
// gulp sass
// Compiles SCSS files in CSS
gulp.task('sass', function () {
gulp.src(basePaths.src 'sass/*.scss')
.pipe(plumber())
.pipe(sourcemaps.init())
.pipe(sass())
.pipe(autoprefixer())
.pipe(sourcemaps.init({loadMaps: true}))
.pipe(sourcemaps.write('.'))
// .pipe(csscomb())
.pipe(gulp.dest(basePaths.assets 'css'))
.pipe(browserSync.stream());
});
// Run:
// gulp concat-css
// concat css file from src
gulp.task('concat-css', function() {
return gulp.src(cssFileList)
.pipe(plumber())
.pipe(concat('bundle.css'))
.pipe(gulp.dest(basePaths.assets 'css/'))
.pipe(browserSync.stream());
});
// Run:
// gulp concat-js
// concat js file from src
gulp.task('concat-js', function() {
return gulp.src(jsFileList)
.pipe(plumber())
.pipe(concat('bundle.js'))
.pipe(gulp.dest(basePaths.assets 'js/'))
.pipe(browserSync.stream());
});
// Run:
// gulp minifycss
// Minifies CSS files
gulp.task('minifycss', function(){
return gulp.src([basePaths.assets 'css/bundle.css', basePaths.assets 'css/theme.css'])
.pipe(plumber())
.pipe(concat('theme.min.css'))
.pipe(minifyCSS({keepBreaks:false,safe: true}))
.pipe(minifyCSS({
reduceIdents: {
keyframes: false
},
discardUnused: {
keyframes: false
},
discardComments: {
removeAll: true
}
}
))
.pipe(gulp.dest(basePaths.assets 'css/'));
});
// Run:
// gulp minifyjs
// Minifies js files
gulp.task('minifyjs', function() {
return gulp.src(basePaths.assets 'js/bundle.js')
.pipe(plumber())
// .pipe(concat('bundle.min.js'))
.pipe(rename({suffix: '.min'}))
.pipe(uglify())
.pipe(gulp.dest(basePaths.assets 'js/'));
});
// Run:
// gulp clean
// Remove file
gulp.task('clean', function () {
return del([
'css/*',
// here we use a globbing pattern to match everything inside the `mobile` folder
'js/*.js',
// we don't want to clean this file though so we negate the pattern
'!css/*.min.css',
'!js/*.min.js'
]);
});
// Run:
// gulp imagemin
// Running image optimizing task
gulp.task('imagemin', function(){
gulp.src(basePaths.src 'img/**')
.pipe(imagemin())
.pipe(gulp.dest(basePaths.assets 'img/'))
});
// Run:
// gulp watch
// Starts watcher. Watcher runs gulp sass task on changes
gulp.task('watch', function () {
// gulp.watch(basePaths.src 'sass/**/*.scss', ['sass']);
gulp.watch(basePaths.src 'sass/**/*.scss', gulp.series('sass'));
gulp.watch(cssFileList,gulp.series('concat-css'));
gulp.watch(jsFileList,gulp.series('concat-js'));
gulp.watch(basePaths.src 'img/**', gulp.series('imagemin'));
//gulp.watch('browser-sync');
});
//task register
// gulp.task('default', ['watch', 'sass', 'concat-css', 'concat-js', 'browser-sync']);
// gulp.task('build', ['sass', 'concat-css', 'concat-js', 'minifycss', 'minifyjs', 'imagemin']);
gulp.task('default', gulp.series('watch', 'sass', 'concat-css', 'concat-js', 'browser-sync'));
gulp.task('build', gulp.series('sass', 'concat-css', 'concat-js', 'minifycss', 'minifyjs', 'imagemin'));