现在我有了这段代码
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/
目录中编译任何内容。我知道这是可能的,但你是怎么做到的?
答案 0 :(得分:1)
我明白了。我刚刚删除了browserfy并将其简化为此
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']);