我正在尝试使用“gulp-uglify”:“3.0.0”来丑化一些javascript文件,但不断收到错误消息。我在捆绑这些文件之前也使用了browserify。
gulp文件中的代码:
var b = browserify({
entries: file,
debug: true
});
return b.bundle()
.pipe(source(file))
.pipe(buffer())
.pipe(uglify().on('error', function (e) {
console.log(e);
}))
.pipe(rename(file.replace(/^Views/, '')))
.pipe(gulp.dest('./dist/js'));
任务运行器控制台输出中抛出的错误:
{ [GulpUglifyError: unable to minify JavaScript]
cause:
{ [SyntaxError: Unexpected token: punc ())]
message: 'Unexpected token: punc ())',
filename: 'Views\\AccountDetails\\ContactDetails.js',
line: 1547,
col: 25,
pos: 50851 },
plugin: 'gulp-uglify',
fileName: 'C:\\_src\\RETIG\\My.TONIKSpace\\My.TonikSpace\\Views\\AccountDetails\\ContactDetails.js',
showStack: false }
{ [GulpUglifyError: unable to minify JavaScript]
cause:
{ [SyntaxError: Unexpected token: punc ())]
message: 'Unexpected token: punc ())',
filename: 'Views\\AccountDetails\\DirectDebitDetails.js',
line: 73,
col: 3,
pos: 2086 },
plugin: 'gulp-uglify',
fileName: 'C:\\_src\\RETIG\\My.TONIKSpace\\My.TonikSpace\\Views\\AccountDetails\\DirectDebitDetails.js',
showStack: false }
{ [GulpUglifyError: unable to minify JavaScript]
cause:
{ [SyntaxError: Unexpected character '`']
message: 'Unexpected character \'`\'',
filename: 'Views\\Usage\\Index.js',
line: 157,
col: 11,
pos: 4109 },
plugin: 'gulp-uglify',
fileName: 'C:\\_src\\RETIG\\My.TONIKSpace\\My.TonikSpace\\Views\\Usage\\Index.js',
showStack: false }
{ [GulpUglifyError: unable to minify JavaScript]
cause:
Process terminated with code 0.
{ [SyntaxError: Unexpected token: punc ())]
message: 'Unexpected token: punc ())',
filename: 'Views\\SharedAccounts\\Index.js',
line: 183,
col: 4,
pos: 5991 },
plugin: 'gulp-uglify',
fileName: 'C:\\_src\\RETIG\\My.TONIKSpace\\My.TonikSpace\\Views\\SharedAccounts\\Index.js',
showStack: false }
{ [GulpUglifyError: unable to minify JavaScript]
cause:
{ [SyntaxError: Unexpected token: punc ())]
message: 'Unexpected token: punc ())',
filename: 'Views\\AccountDetails\\Index.js',
line: 1547,
col: 25,
pos: 50851 },
plugin: 'gulp-uglify',
fileName: 'C:\\_src\\RETIG\\My.TONIKSpace\\My.TonikSpace\\Views\\AccountDetails\\Index.js',
showStack: false }
</code>
我试图通过更改错误引用的标点来解决这些错误,但这感觉不对。无论我是使用单引号还是双引号,为什么不gulp只是丑化文件?