[13:34:30] Using gulpfile ~/works/project/gulpfile.js
[13:34:30] Starting 'default'...
[13:34:30] Starting 'pug'...
[13:34:30] 'pug' errored after 15 ms
[13:34:30] TypeError: dest.on is not a function
at Pumpify.Readable.pipe (/Users/works/project/node_modules/readable-stream/lib/_stream_readable.js:564:8)
at /Users/works/project/gulpfile.js:112:4
at taskWrapper (/Users/works/project/node_modules/undertaker/lib/set-task.js:13:15)
at bound (domain.js:396:14)
at runBound (domain.js:409:12)
at asyncRunner (/Users/works/project/node_modules/async-done/index.js:55:18)
at process._tickCallback (internal/process/next_tick.js:61:11)
[13:34:30] 'default' errored after 20 ms
events.js:200
throw new errors.ERR_INVALID_ARG_TYPE('listener', 'Function', listener);
^
TypeError [ERR_INVALID_ARG_TYPE]: The "listener" argument must be of type Function. Received type object
// gulp
var gulp = require('gulp');
// clean files - clean compiled files before new compilation
var clean = require('gulp-clean');
// show alerts in corner of screen
var notify = require('gulp-notify');
// run a series of gulp tasks in order
var runSequence = require('run-sequence');
// server (localhost) and livereload
const browserSync = require('browser-sync').create();
var reload = browserSync.reload;
// pug (jade) compilation - html-preprocessor
var pug = require('gulp-pug');
// process only changed or new files
// var changed = require('gulp-changed');
// var newer = require('gulp-newer');
// cache files and their contents - process only different (changed) files
var cached = require('gulp-cached');
var filter = require('gulp-filter');
var pugInheritance = require('gulp-pug-inheritance');
// prettify html output
var prettify = require('gulp-html-prettify');
// sass/scss compilation
var sass = require('gulp-sass');
// sass/scss sourcemaps
var sourcemaps = require('gulp-sourcemaps');
// sass/scss global import - you can import all files in directory without writing names - @import "some-folder/**/*"
var sassGlob = require('gulp-sass-glob');
// images optimization - jpg, png, svg
var image = require('gulp-image');
// Paths
var paths = {
dist: {
html: './', // same directory
js: 'js',
css: 'css',
img: 'img',
server: './' // same directory
},
src: {
pug: ['pug/**/*.pug', '!pug/abstracts/bemto/**/*.*'],
pugDir: 'pug',
js: 'js/**/*.js',
sass: 'sass/main.sass',
// sass: ['sass/main.sass', 'sass/bootstrap/bootstrap.scss', 'sass/fontello/fontello.scss', 'sass/font-awesome/font-awesome.scss', 'sass/owl-carousel/owl.carousel.scss'],
img: ['img/**/*']
},
watch: {
pug: 'pug/**/*.pug',
js: 'js/**/*.js',
sass: 'sass/**/*',
img: 'img/**/*',
},
clean: {
css: 'css',
html: '*.html',
templates: 'templates'
}
};
// pug compilation
gulp.task('pug', function() {
return gulp.src(paths.src.pug)
// // only changed files
// .pipe(changed(paths.dist.html, {
// extension: '.html'
// }))
// do not process
.pipe(cached('pug'))
.pipe(pugInheritance({
basedir: paths.src.pugDir,
extension: '.pug',
skip:'node_modules'
}))
.pipe(filter(function (file) {
return !/\/_/.test(file.path) && !/^_/.test(file.relative);
}))
.pipe(pug())
.on('error', notify.onError(function (error) {
return error.message;
}))
.pipe(prettify({
indent_size: 1, // 1 tab
indent_char: ' ' // tab instead spaces
}))
.pipe(gulp.dest(paths.dist.html))
// .pipe(reload({stream: true}));
.pipe(browserSync.reload);
})
// sass compilation
gulp.task('sass', function () {
return gulp.src(paths.src.sass)
.pipe(sassGlob())
.pipe(sourcemaps.init())
.pipe(sass({
errLogToConsole: true,
outputStyle: 'expanded'
}))
.on('error', notify.onError(function (error) {
return error.message;
}))
.pipe(sourcemaps.write())
.pipe(gulp.dest(paths.dist.css))
// .pipe(reload({stream: true}));
.pipe(browserSync.stream());
});
// sass compilation production - without soursemaps, minified
gulp.task('sass-production', function () {
return gulp.src(paths.src.sass)
.pipe(sassGlob())
.pipe(sass({
errLogToConsole: true,
outputStyle: 'compressed'
}))
.on('error', notify.onError(function (error) {
return error.message;
}))
.pipe(gulp.dest(paths.dist.css))
.pipe(reload({stream: true}));
});
// images optimization
gulp.task('img', function () {
return gulp.src(paths.src.img)
// take only changed images
.pipe(cached(paths.src.img))
.pipe(image())
.pipe(gulp.dest(paths.dist.img));
});
// clean
gulp.task('clean', function () {
return gulp.src(
[
paths.clean.css,
paths.clean.html,
paths.clean.templates
],
{
read: false
}
)
.pipe(clean());
});
// server (browserSync) settings
var settings = {
server: {
baseDir: paths.dist.server
},
host: 'localhost',
// port: 9000,
notify: false // don't show message "Connected to BrowserSync"
};
// browserSync server (localhost)
gulp.task('server', function() {
browserSync.init(settings);
});
// watch common files changes for default and production tasks - and re-compile, reload
gulp.task('watch-common', gulp.series('server', function() {
// watch pug
gulp.watch(paths.watch.pug, function(event, cb) {
gulp.start('pug');
}, reload);
// watch js
gulp.watch(paths.watch.js).on('change', reload);
// watch img
gulp.watch(paths.watch.img).on('change', reload);
}));
// watch files changes and re-compile, reload
gulp.task('watch', gulp.series('server', 'watch-common', function() {
// watch sass
gulp.watch(paths.watch.sass, function(event, cb) {
gulp.start('sass');
});
}));
// watch files changes and re-compile, reload
gulp.task('watch-production', gulp.series('server', 'watch-common', function() {
// watch sass and do sass-production
gulp.watch(paths.watch.sass, function(event, cb) {
gulp.start('sass-production');
});
}));
gulp.watch(paths.watch.js).on('change', ['pug']);
// default task
gulp.task('default', gulp.series('pug', 'sass', 'watch', function() {}));
// production
gulp.task('prod', function(cb) {
// run functions in order - first clean (delete) files, then others
runSequence(
'clean',
['img', 'pug', 'sass-production'],
'watch-production',
cb
);
});
assert.js:348
throw err;
^
AssertionError [ERR_ASSERTION]: Task function must be specified
// pug compilation
gulp.task('pug', function() {
return gulp.src(paths.src.pug)
// // only changed files
// .pipe(changed(paths.dist.html, {
// extension: '.html'
// }))
// do not process
.pipe(cached('pug'))
.pipe(pugInheritance({
basedir: paths.src.pugDir,
extension: '.pug',
skip:'node_modules'
}))
.pipe(filter(function (file) {
return !/\/_/.test(file.path) && !/^_/.test(file.relative);
}))
.pipe(pug())
.on('error', notify.onError(function (error) {
return error.message;
}))
.pipe(prettify({
indent_size: 1, // 1 tab
indent_char: ' ' // tab instead spaces
}))
.pipe(gulp.dest(paths.dist.html))
.pipe(browserSync.reload);
})
// sass compilation
gulp.task('sass', function () {
return gulp.src(paths.src.sass)
.pipe(sassGlob())
.pipe(sourcemaps.init())
.pipe(sass({
errLogToConsole: true,
outputStyle: 'expanded'
}))
.on('error', notify.onError(function (error) {
return error.message;
}))
.pipe(sourcemaps.write())
.pipe(gulp.dest(paths.dist.css))
.pipe(browserSync.stream());
});
.pipe(browserSync.reload);
^
SyntaxError: Unexpected token .
at new Script (vm.js:79:7)
at createScript (vm.js:251:10)
at Object.runInThisContext (vm.js:303:10)
at Module._compile (internal/modules/cjs/loader.js:657:28)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
at Module.load (internal/modules/cjs/loader.js:599:32)
at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
at Function.Module._load (internal/modules/cjs/loader.js:530:3)
at Module.require (internal/modules/cjs/loader.js:637:17)
at require (internal/modules/cjs/helpers.js:20:18)
gulp.watch(paths.watch.js).on('change', ['pug']), function() {
.pipe(browserSync.reload);
.pipe(browserSync.stream());
};
// gulp
var gulp = require('gulp');
// clean files - clean compiled files before new compilation
var clean = require('gulp-clean');
// show alerts in corner of screen
var notify = require('gulp-notify');
// run a series of gulp tasks in order
var runSequence = require('run-sequence');
// server (localhost) and livereload
var browserSync = require('browser-sync');
var reload = browserSync.reload;
// pug (jade) compilation - html-preprocessor
var pug = require('gulp-pug');
// process only changed or new files
// var changed = require('gulp-changed');
// var newer = require('gulp-newer');
// cache files and their contents - process only different (changed) files
var cached = require('gulp-cached');
var filter = require('gulp-filter');
var pugInheritance = require('gulp-pug-inheritance');
// prettify html output
var prettify = require('gulp-html-prettify');
// sass/scss compilation
var sass = require('gulp-sass');
// sass/scss sourcemaps
var sourcemaps = require('gulp-sourcemaps');
// sass/scss global import - you can import all files in directory without writing names - @import "some-folder/**/*"
var sassGlob = require('gulp-sass-glob');
// images optimization - jpg, png, svg
var image = require('gulp-image');
// Paths
var paths = {
dist: {
html: './', // same directory
js: 'js',
css: 'css',
img: 'img',
server: './' // same directory
},
src: {
pug: ['pug/**/*.pug', '!pug/abstracts/bemto/**/*.*'],
pugDir: 'pug',
js: 'js/**/*.js',
sass: 'sass/main.sass',
// sass: ['sass/main.sass', 'sass/bootstrap/bootstrap.scss', 'sass/fontello/fontello.scss', 'sass/font-awesome/font-awesome.scss', 'sass/owl-carousel/owl.carousel.scss'],
img: ['img/**/*']
},
watch: {
pug: 'pug/**/*.pug',
js: 'js/**/*.js',
sass: 'sass/**/*',
img: 'img/**/*',
},
clean: {
css: 'css',
html: '*.html',
templates: 'templates'
}
};
// pug compilation
gulp.task('pug', function() {
return gulp.src(paths.src.pug)
// // only changed files
// .pipe(changed(paths.dist.html, {
// extension: '.html'
// }))
// do not process
.pipe(cached('pug'))
.pipe(pugInheritance({
basedir: paths.src.pugDir,
extension: '.pug',
skip:'node_modules'
}))
.pipe(filter(function (file) {
return !/\/_/.test(file.path) && !/^_/.test(file.relative);
}))
.pipe(pug())
.on('error', notify.onError(function (error) {
return error.message;
}))
.pipe(prettify({
indent_size: 1, // 1 tab
indent_char: ' ' // tab instead spaces
}))
.pipe(gulp.dest(paths.dist.html))
.pipe(reload({stream: true}));
})
// sass compilation
gulp.task('sass', function () {
return gulp.src(paths.src.sass)
.pipe(sassGlob())
.pipe(sourcemaps.init())
.pipe(sass({
errLogToConsole: true,
outputStyle: 'expanded'
}))
.on('error', notify.onError(function (error) {
return error.message;
}))
.pipe(sourcemaps.write())
.pipe(gulp.dest(paths.dist.css))
.pipe(reload({stream: true}));
});
// sass compilation production - without soursemaps, minified
gulp.task('sass-production', function () {
return gulp.src(paths.src.sass)
.pipe(sassGlob())
.pipe(sass({
errLogToConsole: true,
outputStyle: 'compressed'
}))
.on('error', notify.onError(function (error) {
return error.message;
}))
.pipe(gulp.dest(paths.dist.css))
.pipe(reload({stream: true}));
});
// images optimization
gulp.task('img', function () {
return gulp.src(paths.src.img)
// take only changed images
.pipe(cached(paths.src.img))
.pipe(image())
.pipe(gulp.dest(paths.dist.img));
});
// clean
gulp.task('clean', function () {
return gulp.src(
[
paths.clean.css,
paths.clean.html,
paths.clean.templates
],
{
read: false
}
)
.pipe(clean());
});
// server (browserSync) settings
var settings = {
server: {
baseDir: paths.dist.server
},
host: 'localhost',
// port: 9000,
notify: false // don't show message "Connected to BrowserSync"
};
// browserSync server (localhost)
gulp.task('server', function() {
browserSync(settings);
});
// watch common files changes for default and production tasks - and re-compile, reload
gulp.task('watch-common', ['server'], function(){
// watch pug
gulp.watch(paths.watch.pug, function(event, cb) {
gulp.start('pug');
}, reload);
// watch js
gulp.watch(paths.watch.js).on('change', reload);
// watch img
gulp.watch(paths.watch.img).on('change', reload);
});
// watch files changes and re-compile, reload
gulp.task('watch', ['server', 'watch-common'], function(){
// watch sass
gulp.watch(paths.watch.sass, function(event, cb) {
gulp.start('sass');
});
});
// watch files changes and re-compile, reload
gulp.task('watch-production', ['server', 'watch-common'], function() {
// watch sass and do sass-production
gulp.watch(paths.watch.sass, function(event, cb) {
gulp.start('sass-production');
});
});
// default task
gulp.task('default', ['pug', 'sass', 'watch']);
// production
gulp.task('prod', function(cb) {
// run functions in order - first clean (delete) files, then others
runSequence(
'clean',
['img', 'pug', 'sass-production'],
'watch-production',
cb
);
});