2014-09-10 79 views
4

在此Gulp任務中,vendorFiles代碼位於dest style.css文件中的appFiles代碼之後。在具有Gulp事件流的concat流時的順序

是因爲appFiles流運行速度更快嗎?如何像預期的那樣讓vendorFiles代碼出現?

gulp.task('styles', function() { 

    var vendorFiles = gulp.src(mainBowerFiles()) // don't read 
     .pipe(gulpFilter('*.css')); 

    var appFiles = gulp.src('app/sass/*.scss') 
     .pipe(sass()) 
     .pipe(prefix('> 5%')); 

    return es.concat(vendorFiles, appFiles) 
     .pipe(minifyCSS()) 
     .pipe(concat('style.css')) 
     .pipe(gulp.dest('./dist/css')); 
}); 

回答

4

gulp-order

gulp.task('scripts', function() { 

    var jsFilter = gulpFilter('*.js'); 
    var vendorFiles = gulp.src(mainBowerFiles()) 
     .pipe(jsFilter) 
     .pipe(concat('vendor.js')); 

    var appFiles = gulp.src('app/js/*.js') 
     .pipe(jshint()) 
     .pipe(jshint.reporter('default')) 
     .pipe(concat('app.js')); 

    return eventStream.concat(vendorFiles, appFiles) 
     .pipe(order([ 
      "vendor.js", 
      "app.js" 
     ])) 
     .pipe(concat('app.js')) 
     .pipe(uglify()) 
     .pipe(gulp.dest('./dist/js')); 
}); 
解決它