DMH
DMH

Reputation: 2809

Unexpected token : options: { when using Grunt

I am looking to use grunticon to generate png's of my SVG's I have the following setup here: 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']);
};

When i run grunt in terminal I get the following error

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.

Can anyone help me out to why this may be happening?

Upvotes: 0

Views: 742

Answers (1)

Xavier Priour
Xavier Priour

Reputation: 2121

Your task setup (but not the task registration) should be done inside a call to grunt.initConfig() - note the second line and last but 2 below. Also, you need to load grunticon (see last lines):

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']);
};

Upvotes: 2

Related Questions