这是我的 Gruntfile.js
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON("package.json"),
uglify: {
options: {
mangle: true
}
build: {
src: "js/*.js",
dest: "js/min/script.js"
}
}
});
grunt.loadNpmTasks("grunt-contrib-uglify");
grunt.registerTask('default', [uglify]);
};
这是我的 package.json - 我已经运行npm install
了所有我将在我的 Gruntfile 中使用的插件,grunt-contrib-uglify 就是其中之一。
{
"name": "bootbuckle",
"version": "0.1.0",
"engines": {
"node": ">= 0.10.0"
},
"devDependencies": {
"grunt": "~0.4.2",
"grunt-contrib-watch": "~0.5.3",
"grunt-contrib-sass": "~0.6.0",
"grunt-csscomb": "~2.0.1",
"grunt-contrib-htmlmin": "~0.1.3",
"grunt-contrib-imagemin": "~0.4.1",
"grunt-contrib-uglify": "~0.2.7"
}
}
当我只是grunt
在终端中运行时 - 这是错误
build: {
^^^^^
Loading "Gruntfile.js" tasks...ERROR
>> SyntaxError: Unexpected identifier
Warning: Task "default" not found. Use --force to continue.
Aborted due to warnings.
提前感谢您提供的任何帮助。
编辑按照马蒂的指导,我插入了一个缺少的逗号,现在抛出了一个新错误
Loading "Gruntfile.js" tasks...ERROR
>> ReferenceError: uglify is not defined
Warning: Task "default" not found. Use --force to continue.
Aborted due to warnings.