javascript - Gulp - 使用 gulp-uglify 和 gulp-concat 的意外 token 错误

标签 javascript node.js gulp uglifyjs

这是我的代码

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/

相关文章:

javascript - requestFrameAnimation 使用持续时间时断断续续

node.js - 如何在 NodeJS 上验证 AWS Cognito 访问 token

javascript - Gulp-uglify 包装 JS

javascript - 如何使用 gulp-inject 将文件的内容插入到我的 index.html 中?

javascript - 分配给 onclick() 时未定义的函数

javascript - 如何使用 jQuery 获取列表子元素的文本

javascript - 使用 JS-grid 实现添加列

node.js - Sails.js 应用程序看不到 index.ejs?

Gulp总是抛出错误 Cannot find module 'gulp-util'

javascript - 如何提高webpack性能?