Gulp build命令给我这个错误信息

时间:2018-04-10 00:42:25

标签: gulp

$ gulp build
[02:36:37] Using gulpfile C:\xampp\htdocs\melodic\gulpfile.js
[02:36:37] Starting 'build'...
[02:36:37] Starting 'clean:dist'...
[02:36:37] Finished 'clean:dist' after 4.63 ms
[02:36:37] Starting 'sass'...
[02:36:37] Starting 'useref'...
[02:36:37] Starting 'img'...
[02:36:37] Starting 'cleancss'...
[02:36:37] Finished 'cleancss' after 37 ms
C:\xampp\htdocs\melodic\node_modules\gulp-useref\node_modules\vinyl- 
fs\lib\src\index.js:20
throw new Error('Invalid glob argument: ' + glob);
^

Error: Invalid glob argument:
at Object.src (C:\xampp\htdocs\melodic\node_modules\gulp- 
useref\node_modules\vinyl-fs\lib\src\index.js:20:11)
at DestroyableTransform.addAssetsToStream 
(C:\xampp\htdocs\melodic\node_modules\gulp-useref\index.js:62:15)
at C:\xampp\htdocs\melodic\node_modules\gulp-useref\index.js:124:31
at Array.forEach (native)
at DestroyableTransform.processAssets 
(C:\xampp\htdocs\melodic\node_modules\gulp-useref\index.js:115:11)
at C:\xampp\htdocs\melodic\node_modules\gulp-useref\index.js:178:31
at Stream.<anonymous> (C:\xampp\htdocs\melodic\node_modules\gulp- 
useref\node_modules\event-stream\index.js:318:20)
at _end (C:\xampp\htdocs\melodic\node_modules\through\index.js:65:9)
at Stream.stream.end 
(C:\xampp\htdocs\melodic\node_modules\through\index.js:74:5)
at DestroyableTransform.onend 
(C:\xampp\htdocs\melodic\node_modules\through2\node_modules\readable- 
stream\lib\_stream_readable.js:577:10)

我试图逐个删除正在运行的任务,但无济于事。让我失望的是,它似乎贯穿了所有任务,甚至完成它们,然后在最后一个任务完成时崩溃。提前谢谢。

编辑:这是我的gulpfile,因为我忘了包含它。

     var gulp = require('gulp');
     // Requires the gulp-sass plugin
     var sass = require('gulp-sass');
     //Requires browser synch
     var browserSync = require('browser-sync').create();
     //Requires userref
     var useref = require('gulp-useref');
     //Requires uglify
     var uglify = require('gulp-uglify');
     var gulpIf = require('gulp-if');
    //Requires cssnano
    var cssnano = require('gulp-cssnano');
    //Requires imagemin
    var imagemin = require('gulp-imagemin');
    //Requires cache
    var cache = require('gulp-cache');
    //Requires del
    var del = require('del');
    //Requires run-sequence
    var runSequence = require('run-sequence');
    //requires postcss
    var postcss = require('gulp-postcss');

    //ACTIVE COMMANDS

    /*Run 'gulp browserSync' in commandline.
    This task automatically reloads the broswer upon each save of document*/
    gulp.task('browserSync', function() {
    browserSync.init({
    injectChanges: true,
    server: {
      baseDir: "./app"
    },
  })
});



/*Run 'gulp sass' in command line.
THIS TASK GETS ALL SCSS IMPORTED INTO THE app.scss FILE AND CONVERTS IT INTO app.css.
THIS TASK IS A ONE TIME CONVERSTION*/
gulp.task('sass', function() {
  return gulp.src('app/scss/**/*.scss') // Gets all files ending with .scss in app/scss
    .pipe(sass())
    .pipe(gulp.dest('app/css'))
    .pipe(browserSync.stream({match: '**/*.css'}));
});



/*Run 'gulp watch' in command line.
THIS TASK GETS ALL SCSS AND OTHER FILE TYPES AND CONVERTS THEM ACITVELY.
THIS TASK IS ONGOING*/
gulp.task('watch', ['browserSync', 'sass'], function (){
  gulp.watch('app/scss/**/*.scss', ['sass']);
});



//PRODUCTION/FINAL COMMANDS


/*Run 'gulp useref' in command line.
THIS TASK GETS ALL CSS AND OTHER FILE TYPES AND JOINS DIFFERENT FILES AND MINIMIZES THEM IN THE DIST FOLDER.
*/
gulp.task('useref', function(){
  return gulp.src('app/*.html')
    .pipe(useref())
    // Minifies only if it's a JavaScript file
    .pipe(gulpIf('*.js', uglify()))
    // Minifies only if it's a CSS file
    .pipe(gulpIf('*.css', cssnano()))
    .pipe(gulp.dest('dist'))
});

gulp.task('cleancss', function () {
    return gulp.src('./src/*.css')
        .pipe(postcss())
        .pipe(gulp.dest('./dest'));
});

/*Run 'gulp img' in command line.
MINIMIZSES PHOTOS TO THE DIST FOLDER*/
gulp.task('img', function(){
  return gulp.src('app/img/**/*.+(png|jpg|gif|svg)')
  .pipe(imagemin({
    // Setting interlaced to true
    interlaced: true
  }))
    // Caching images that ran through imagemin
  .pipe(cache(imagemin({
      interlaced: true
    })))
  .pipe(gulp.dest('dist/img'))
});

/*Run 'gulp fonts' in command line.
CLEANS THE DIST DIRECTORY FOR UNUSED FILES*/
gulp.task('clean:dist', function() {
  return del.sync('dist');
});


/*Run 'gulp fonts' in command line.
CLEANS THE IMAGE CACHE CREATED EARLIER*/
gulp.task('cache:clear', function (callback) {
return cache.clearAll(callback)
});


gulp.task('build', function (callback) {
  runSequence('clean:dist',
    ['sass', 'useref', 'img', 'cleancss'],
    callback
  )
});

gulp.task('default', function (callback) {
  runSequence(['sass','browserSync', 'watch'],
    callback
  )
  });

编辑:包含我的gulpfile以获取更多详细信息。

0 个答案:

没有答案