这是我的代码
gulp.task('js', function () {
return gulp.src(['public/js/angular.js','public/js/app.js', 'public/js/**/*.js'])
.pipe(plumber({
errorHandler: function(err){
console.log(err);
this.emit('end');
}
}))
.pipe(concat('filename.min.js'))
.pipe(uglify().on('error', gutil.log))
.pipe(gulp.dest('public/js') //destination of new file
.pipe(notify({ message: 'Finished minifying JavaScript'})))
gulp.task('watch', function(){
gulp.watch('app/assets/sass/**/*', ['css']);
gulp.watch('public/js/**/*', ['js']);
});
更改任何 js 文件后的控制台错误:
/projects/miche-web/public/js/miche.min.js: Unexpected token name «replace», expected punc «,»] message: '/Users/projects/miche-web/public/js/miche.min.js: Unexpected token name «replace», expected punc «,»', fileName: '/Users/projects/miche-web/public/js/miche.min.js', lineNumber: 247,
但是,该文件是空白的,所以我无法引用第 247 行的错误。
有什么想法吗?
最佳答案
您的 pipe
调用中存在语法错误。观察以下...
.pipe(gulp.dest('public/js') //destination of new file
=>
.pipe(gulp.dest('public/js')) //destination of new file
注意在初始函数调用中缺少 )
关于javascript - Gulp - 使用 gulp-uglify 和 gulp-concat 的意外 token 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35328069/