这是我的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.
非常感谢您可能提供的任何帮助。
编辑 遵循Matti的指导,我插入了一个缺失的逗号,现在出现了一个新错误。
Loading "Gruntfile.js" tasks...ERROR
>> ReferenceError: uglify is not defined
Warning: Task "default" not found. Use --force to continue.
Aborted due to warnings.