Gulp只运行依赖任务,但不运行主要任务

时间:2017-01-06 19:52:16

标签: gulp

所以我有一个gulpfile.js在过去几个月里按预期工作。我确实删除了node_modules目录并运行了npm install。我真的不认为我改变了其他任何东西。但是现在当我尝试运行主任务(名为“default”)时,它只运行一个任务(名为“clean”)然后停止。如果我删除对clean任务的所有依赖,则运行“default”的所有子任务。我无法弄清楚为什么。我被卡住了!

var gulp = require('gulp');
var merge = require('merge-stream');
var sass = require('gulp-sass');
var inject = require('gulp-inject');
var wiredep = require('wiredep').stream;
var del = require('del');
var uglify = require('gulp-uglify');
var cleanCSS = require('gulp-clean-css');

gulp.task('clean', function (cb) {
    del(['assets-dist'], cb);
});

gulp.task('styles', ['clean'], function() {
    var injectAppFiles = gulp.src('assets-src/styles/*.scss', {read: false});
    var injectGlobalFiles = gulp.src('assets-src/global/*.scss', {read: false});

    function transformFilepath(filepath) {
    return '@import "' + filepath + '";';
    };

    var injectAppOptions = {
    transform: transformFilepath,
    starttag: '// inject:app',
    endtag: '// endinject',
    addRootSlash: false
    };

    var injectGlobalOptions = {
    transform: transformFilepath,
    starttag: '// inject:global',
    endtag: '// endinject',
    addRootSlash: false
    };

    return gulp.src('assets-src/main.scss')
    .pipe(wiredep())
    .pipe(inject(injectGlobalFiles, injectGlobalOptions))
    .pipe(inject(injectAppFiles, injectAppOptions))
    .pipe(sass())
    .pipe(cleanCSS({compatibility: 'ie8'}))
    .pipe(gulp.dest('assets-dist/css'));
});


gulp.task('js', ['clean'], function() {
    var bootstrap = gulp.src(
    ['bower_components/bootstrap-sass/assets/javascripts/bootstrap.js',
    ])
    .pipe(uglify())
    .pipe(gulp.dest('assets-dist/js'));

    var misc = gulp.src(['assets-src/js/*.js'])
        .pipe(uglify())
        .pipe(gulp.dest('assets-dist/js'));

    return merge(bootstrap, misc);
});


gulp.task('bootstrapfonts', ['clean'], function() {
   gulp.src('bower_components/bootstrap-sass/assets/fonts/bootstrap/*.{ttf,woff,woff2,eot,svg}')
   .pipe(gulp.dest('assets-dist/fonts/bootstrap'));
});


gulp.task('images', ['clean'], function() {
   gulp.src('assets-src/images/**/*.{jpg,png,svg,ico}')
   .pipe(gulp.dest('assets-dist/images'));
});


gulp.task('default', ['styles', 'js', 'images', 'bootstrapfonts'], function() {
    var injectFiles = gulp.src(['assets-dist/css/main.css']);

    var injectOptions = {
    addRootSlash: false,
    ignorePath: ['src', 'dist']
    };

    return gulp.src('src/index.html')
    .pipe(inject(injectFiles, injectOptions))
    .pipe(gulp.dest('dist'));
});

的package.json:

{
  "name": "LoreIpsum",
  "version": "1.0.0",
  "description": "Lorem ipsum",
  "main": "index.js",
  "private": true,
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "bower": "^1.7.9",
    "del": "^1.2.0",
    "gulp": "^3.9.1",
    "gulp-clean-css": "^2.0.12",
    "gulp-inject": "^4.1.0",
    "gulp-sass": "^2.3.2",
    "gulp-uglify": "^1.5.4",
    "gulp-uncss": "^1.0.6",
    "merge-stream": "^1.0.0",
    "wiredep": "^4.0.0"
  },
  "dependencies": {
  }
}

输出:

nine at nine-thinkpad in ~/Dev/Hemsidor/WebApp (python3●●) (WebApp) 
$ node_modules/.bin/gulp --version
[22:22:55] CLI version 3.9.1
[22:22:55] Local version 3.9.1

nine at nine-thinkpad in ~/Dev/Hemsidor/WebApp (python3●●) (Webapp) 
$ node_modules/.bin/gulp default  
[22:23:02] Using gulpfile ~/Dropbox/Dev/Hemsidor/Webapp/gulpfile.js
[22:23:02] Starting 'clean'...

0 个答案:

没有答案