2015-06-08 74 views
1

現在我有這樣的代碼讓一飲而盡手錶和編譯整個目錄ES6

var gulp = require('gulp'); 
var babel = require('gulp-babel'); 

var babelify = require('babelify'); 
var browserify = require('browserify'); 
var source = require('vinyl-source-stream'); 

gulp.task('watch', function() { 
    gulp.watch('./scripts/es6/*.es6', ['modules']) 
}); 

gulp.task('modules', function() { 
    browserify({ 
    entries: './scripts/es6/popup.es6', 
    debug: true 
    }) 
    .transform(babelify) 
    .bundle() 
    .pipe(source('popup.js')) 
    .pipe(gulp.dest('./scripts')); 
}); 

現在它只是編譯popup.es6當它改變,但我想它來編譯./scripts/es6/下的任何內容。我知道這是可能的,但你怎麼做?

回答

1

我想通了。我剛剛刪除了瀏覽器並將其簡化爲此

var gulp = require('gulp'); 
var sourcemaps = require('gulp-sourcemaps'); 
var babel = require('gulp-babel'); 
var gutil = require('gulp-util'); 

var path = require('path'); 

gulp.task('babel', function() { 
    return gulp.src('./scripts/es6/*.es6') 
     .pipe(babel()) 
     .pipe(gulp.dest('./scripts')); 
}); 

gulp.task('watch', function() { 
    gulp.watch('./scripts/es6/*.es6', ['babel']); 
}); 

gulp.task('default', ['watch']);