I
I
Ivan Dobroslavin2018-11-15 00:31:58
gulp.js
Ivan Dobroslavin, 2018-11-15 00:31:58

How to fix error when running gulp?

'use strict';
// Import all of our gulp plugins and gulp itself
var gulp = require('gulp'),
watch = require('gulp-watch'),
prefixer = require('gulp-autoprefixer'),
uglify =require('gulp- uglify'),
sass = require('gulp-sass'),
sourcemaps =require('gulp-sourcemaps'),
rigger = require('gulp-rigger'),
cssmin = require('gulp-minify-css'),
imagemin =require('gulp-imagemin'),
tinypng = require('gulp-tinypng'),
rimraf = require('rimraf'),
browserSync = require('browser-sync'),
reload = browserSync.reload;
var path = {
build: { //specify
js: 'build/js/',
css: 'build/css/',
img: 'build/img/',
fonts: 'build/fonts/'
},
src: { // Paths where we will take the
html sources: 'src/*.html', // The src/*.html syntax tells gulp that we want to take all files with a .html extension
js: 'src/js/main.js', // In styles and scripts, we only need main-files
style: 'src/style/main.scss',
img: 'src/img/**/*.*' // The img/**/*.* syntax means "get all the files in the img folder and all subfolders with any extension
},
clean: '.build'
};
// Create a variable with the settings of our dev server:
var config = {
server:{
baseDir: ".build"
},
tunnel: true,
host: 'localhost',
port: 9000,
logPrefix: "Frontend_Devil"
};
// BUILD HTML
// Write a tax to build html:
gulp.task('html:build', function () {
gulp.src(path.src.html) // Select files by path
.pipe(rigger()) // Run it through the rigger
.pipe(gulp.dest(path.build.html)) // Spit them out into the folder byild
.pipe(reload({stream: true})); // And reload our server for updates
});
// Rigger is a plugin that allows you to use this construction to import files:
//= template/footer.html
// BUILD JAVASCRIPT // The
task for building scripts looks like this:
gulp.task('js:build', function () {
gulp.src(path.src.js) // Find Our Main File
.pipe(rigger()) // Run Through The Rigger
.pipe(sourcemaps.init( )) // Initialize sourcemaps
.pipe(uglify()) // Compress our js
.pipe(sourcemaps.write()) // Write maps
.pipe(gulp.dest(path.build.js)) // Spit out the finished file
.pipe(reload({stream: true})); // And restart the server
});
// ASSEMBLE STYLES
// Task to build our scss
gulp.task('style:build', function() {
gulp.src(path.src.style) // Select our main.scss
.pipe(sourcemaps.init() ) // Initialize sourcemap
.pipe(sass()) // Compile
.pipe(prefixer()) // Add vendor prefixes
.pipe(cssmin()) // Compress
.pipe(sourcemaps.write())
.pipe(gulp.dest(path.build.css)) // Build
.pipe (reload({stream: true}));
});
//
BUILD IMAGES gulp.task('image:build', function() {
gulp.src(path.src.img) // Select our images
.pipe(imagemin({ // Compress them
progressive:true,
svgoPlagins: [ {removeViewBox: false}],
use: [pngquant()],
interlaced: true
}))
.pipe(gulp.dest(path.build.img)) // and spit it into the
Build .pipe(reload({stream: true }));
});
// FONTS
gulp.task('fonts:build', function() {
gulp.src(path.src.fonts)
.pipe(gulp.dest(path.build.fonts))
});
// Run all previous tasks
gulp.task('build', [
'html:build',
'js:build',
'style:build',
'fonts:build',
'image:build'
]);
gulp.task('watch', function(){
watch([path.watch.html], function(event, cb) {
gulp.start('html:build');
});
watch([path.watch. style], function(event, cb) {
gulp.start('style:build');
});
watch([path.watch.js], function(event, cb) {
gulp.start('js:build' );
});
watch([path.
gulp.start('image:build');
});
watch([path.watch.fonts], function(event, cb) {
gulp.start('fonts:build');
});
});
gulp.task('webserver', function() {
browserSync(config);
});
gulp.task('clean', function (cb) {
rimraf(path.clean, cb);
});
gulp.task('default', ['build', 'webserver', 'watch']);
Here is the error when running gulp:
C:\2018>gulp
[00:28:19] Using gulpfile C:\2018\gulpfile.js
[00:28:19] Starting 'html:build'...
[00:28 :19] Finished 'html:build' after 7.73 ms
[00:28:19] Starting 'js:build'...
[00:28:
[00:28:19] Starting 'style:build'...
[00:28:19] Finished 'style:build' after 2.63 ms
[00:28:19] Starting 'fonts:build'...
[00 :28:19] 'fonts:build' errored after 119 ?s
[00:28:19] Error: Invalid glob argument: undefined
at Gulp.src (C:\2018\node_modules\vinyl-fs\lib\src\index .js:20:11)
at Gulp. (C:\2018\gulpfile.js:114:7)
at module.exports (C:\2018\node_modules\orchestrator\lib\runTask.js:34:7)
at Gulp.Orchestrator._runTask (C:\2018\ node_modules\orchestrator\index.js:27
3:3)
at Gulp.Orchestrator._runStep (C:\2018\node_modules\orchestrator\index.js:21
4:10)
at C:\2018\node_modules\orchestrator\index. js:279:18
at finish (C:\2018\node_modules\orchestrator\lib\runTask.js:21:8)
at module.exports (C:\2018\node_modules\orchestrator\lib\runTask.js:60:3)
at Gulp.Orchestrator ._runTask (C:\2018\node_modules\orchestrator\index.js:27
3:3)
at Gulp.Orchestrator._runStep (C:\2018\node_modules\orchestrator\index.js:21
4:10)
C:\2018 >

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Andrey Sanych, 2018-11-15
@mountpoint

somewhere in this file gulp.src() is catching an empty (undefined) argument. Check path.src.style, path.src.js and other arguments

D
Dmitry Chashchinov, 2018-11-15
@kudesa

What version of gallp is installed?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question