我使用grunt来丑化三个JavaScript文件:
我收到此错误:
Warning: Uglification failed.
Name expected.
Line 38 in src/js/functions.js
Use --force to continue.
functions.js
的第38行:
for (var [id, value] of formData.entries()) {
对于for ...或formData,这是否失败?
Gruntfile.js
:
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
watch: {
uglify: {
files: [ 'src/js/*' ],
tasks: 'uglify'
}
},
uglify: {
my_target: {
files: {
'public/js/<%= pkg.name %>.min.js': ['src/js/*.js']
}
}
}
});
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-uglify');
};
答案 0 :(得分:2)
通过切换到grunt-contrib-uglify
的{{3}}来解决此问题。主分支目前不支持ES6。
在我的packages.json中,我换掉了原来的行并运行了npm install
:
"grunt-contrib-uglify": "git://github.com/gruntjs/grunt-contrib-uglify.git#harmony"