意外的标记:选项:{ 使用 Grunt 时
Unexpected token : options: { when using Grunt
我希望使用 g运行ticon 生成我的 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": "",
"license": "ISC",
"devDependencies": {
"grunt": "^0.4.5",
"grunt-grunticon": "^2.2.0",
"grunt-svgmin": "^2.0.1"
}
}
Gruntfile.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']);
};
当我在终端中 运行 g运行t 时,出现以下错误
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']);
};
我希望使用 g运行ticon 生成我的 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": "",
"license": "ISC",
"devDependencies": {
"grunt": "^0.4.5",
"grunt-grunticon": "^2.2.0",
"grunt-svgmin": "^2.0.1"
}
}
Gruntfile.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']);
};
当我在终端中 运行 g运行t 时,出现以下错误
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']);
};