这是我的代码
var gulp = require('gulp');
var browserify = require('gulp-browserify');
var rename = require('gulp-rename');
var uglify = require('gulp-uglify');
gulp.task('js', function () {
gulp.src('js/main.js')
.pipe(browserify())
.pipe(rename('js/bundle.js'))
.pipe(uglify())
.pipe(gulp.dest('./'));
})
gulp.task('watch', function () {
gulp.watch('js/*.js', ['js']);
})
答案 0 :(得分:0)
尝试以下方法:
var gulp = require('gulp');
var browserify = require('gulp-browserify');
var uglify = require('gulp-uglify');
var source = require('vinyl-source-stream');
gulp.task(
browserify('js/main.js')
.bundle()
.pipe(source('bundle.js'))
.pipe(uglify())
.pipe(gulp.dest('./'));
});
gulp.task('watch', function () {
gulp.watch('js/*.js', ['js']);
})