任何人都可以告诉我为什么在运行以下grunt.js文件时我在终端中收到以下错误?
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
concat: { // Here is where we do our concatenating
dist: {
src: [
'components/js/*.js' // everything in the src js folder
],
dest: 'js/script.js',
}
}
uglify: {
build: {
src: 'js/script.js',
dest: 'js/script.min.js'
}
}
});
//Add all the plugins here
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-uglify');
//What happens when we type 'grunt' in the terminal
grunt.registerTask('default', ['concat', 'uglify']);
};
我得到的错误是:
Loading "gruntfile.js" tasks...ERROR
SyntaxError:意外的标识符 警告:找不到任务“默认”。使用--force继续。
谢谢!
答案 0 :(得分:12)
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
concat: {
dist: {
src: [
'components/js/*.js'
],
dest: 'js/script.js',
}
}, // <---- here was a missing comma
uglify: {
build: {
src: 'js/script.js',
dest: 'js/script.min.js'
}
}
});
module.exports = (grunt) ->
grunt.initConfig
pkg: grunt.file.readJSON("package.json")
concat:
dist:
src: ["components/js/*.js"]
dest: "js/script.js"
uglify:
build:
src: "js/script.js"
dest: "js/script.min.js"
grunt.loadNpmTasks "grunt-contrib-concat"
grunt.loadNpmTasks "grunt-contrib-uglify"
grunt.registerTask "default", [
"concat"
"uglify"
]