Gruntjs 意外标记:选项:{使用Grunt时
我希望使用grunticon生成SVG的png,我在这里有以下设置: Package.jsonGruntjs 意外标记:选项:{使用Grunt时,gruntjs,Gruntjs,我希望使用grunticon生成SVG的png,我在这里有以下设置: Package.json { "name": "svg-to-png", "version": "1.0.0", "description": "", "main": "index.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, "keywords": [], "author": "", "l
{
"name": "svg-to-png",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"grunt": "^0.4.5",
"grunt-grunticon": "^2.2.0",
"grunt-svgmin": "^2.0.1"
}
}
Grunfile.js
module.exports = function(grunt) {
grunticon: {
siteIcons: {
files: [{
expand: true,
cwd: '../../public/images/icons',
src: ['*.svg', '*.png'],
dest: 'dest'
}],
options: {
colors: {
white: '#ffffff',
green: '#60d134',
}
}
}
},
grunt.registerTask('default', ['grunticon:siteIcons']);
};
当我在终端中运行grunt时,我得到以下错误
Loading "Gruntfile.js" tasks...ERROR
>> SyntaxError: /Users/damien/codeclub/design/config/grunt/Gruntfile.js:10
>> options: {
>> ^
>> Unexpected token :
Warning: Task "default" not found. Used --force, continuing.
Done, but with warnings.
有人能帮我解释一下为什么会发生这种情况吗?您的任务设置(而不是任务注册)应该在调用grunt.initConfig()
的过程中完成-请注意下面的第二行和最后2行。
此外,还需要加载grunticon(请参见最后几行):
module.exports = function(grunt) {
grunt.initConfig({
grunticon: {
siteIcons: {
files: [{
expand: true,
cwd: '../../public/images/icons',
src: ['*.svg', '*.png'],
dest: 'dest'
}],
options: {
colors: {
white: '#ffffff',
green: '#60d134',
}
}
}
}
});
grunt.loadNpmTasks('grunt-grunticon');
grunt.registerTask('default', ['grunticon:siteIcons']);
};