这是我的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
,我将在我的grunt文件中使用所有的插件,grunt-contrib plugins就是其中之一。
{
"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.
https://stackoverflow.com/questions/21062362
复制相似问题