我一直收到错误:
"由于警告而被麻醉。 S C:\ atomworkspace \ angularproject \ conFusion>咕噜 oading" Gruntfile.js"任务...错误
SyntaxError:意外的标识符 arning:任务"默认"未找到。使用--force继续。 "
我希望Grunt可以指向gruntfile中出现语法错误的行号。坦率地说,这应该是默认包装。对我来说似乎很常见。无论如何这里是我的代码。我无法找到问题所在。有人请帮忙。
'use strict';
module.exports = function(grunt) {
//time how long the tasks take.
require('time-grunt')(grunt);
//automatically load required grunt tasks
require('jit-grunt')(grunt, {useminPrepare: 'grunt-usemin'
});
// Define the configuration for all the tasks
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
//Make sure code styles are up to par and there are no obvious mistakes
jshint: {
options: {
jshintrc: '.jshintrc',
reporter: require('jshint-stylish')
},
all: {
src: [
'Gruntfile.js',
'app/scripts/{,*/}*.js'
]
}
}
copy: {
dist: {
cwd: 'app',
src: ['**', '!styles/**/*.css', '!scripts/**/*.js'],
dest: 'dist',
expand: 'true'
},
fonts: {
files: [{
//for bootstrap fonts
expand: true,
dot: true,
cwd: 'bower_components/bootstrap/dist',
src: ['fonts/*,*'],
dest: 'dist'
}]
}
},
clean: {
build: {
src: ['dist/']
}
},
useminPrepare: {
html: 'app/menu.html'
options: {
dest: 'dist'
}
},
//Concat
concat: {
options: {
separator: ';'
},
//dist configuration given by useminPrepare
dist: {}
},
//Uglify
Uglify: {
//dist configuration given by useminPrepare
dist: {}
},
cssmin: {
dist: {}
},
//Filerev
filerev: {
options: {
encoding: 'utf8',
algorithm: 'md5',
length: 20
},
release: {
//Filerev: release hashes(md5) all assets (images, js, and css)
// in dist direcftory
// brackets are used to specify file
files: [{
src: [
'dist/scripts/*.js',
'dist/styles/*.css',
]
}]
}
},
//useminPrepare``
//Replace all assets with their recent version in html and css files.
//options.assetDirs holds the directories for finding the assets
usemin: {
html: ['dist/*.html'],
css: ['dist/styles/*.css'],
options: {
assetDirs: ['dist', 'dist/styles']
}
}
});
grunt.registerTask('build', [
'clean',
'jshint',
'useminPrepare',
'concat',
'cssmin',
'uglify',
'copy',
'filerev',
'usemin'
]);
grunt.registerTask('default', ['build']);
};
答案 0 :(得分:3)
尝试使用},
copy: {
获取更具体的错误消息。
您在复制任务之前缺少逗号:
html:
和useminPrepare
任务中的 useminPrepare: {
html: 'app/menu.html',
字段后面的一个:
{{1}}