selaux / node-sprite-generator

Generates image sprites and their spritesheets (css, stylus, sass or less) from sets of images. Supports retina sprites. Provides express middleware and grunt task.
MIT License
192 stars 39 forks source link

allow global task options in gruntfile #32

Closed scott-kennedy closed 9 years ago

scott-kennedy commented 9 years ago

This commit allows global options in a gruntfile and merges them with the existing options for each task. It reduces the amount of duplication needed in the gruntfile when you have multiple tasks that all use the same base options.

Ex gruntfile before:

spriteGenerator: {
    taskOne: {
        compositor: 'gm',
        compositorOptions: {
            compressionLevel: 9
        },
        layout: 'diagonal',
        src: [
            '<%= dirs.root %>/images/icons/*.png'
        ],
        spritePath: '<%= dirs.root %>/images/sprite.png',
        stylesheetPath: '<%= dirs.css %>_sprites.scss',
        stylesheet: 'scss',
        stylesheetOptions: {
            pixelRatio: 2
        }
    },
    taskTwo: {
        compositor: 'gm',
        compositorOptions: {
            compressionLevel: 9
        },
        layout: 'diagonal',
        src: [
            '<%= dirs.root %>/images/icons/blue/*.png'

        ],
        spritePath: '<%= dirs.root %>/images/sprite.png',
        stylesheetPath: '<%= dirs.css %>_sprites.scss',
        stylesheet: 'scss',
        stylesheetOptions: {
            pixelRatio: 2
        }
    }
}

Ex grunfile after:

spriteGenerator: {
    options: {
        compositor: 'gm',
        compositorOptions: {
            compressionLevel: 9
        },
        layout: 'diagonal',
        stylesheet: 'scss',
        stylesheetOptions: {
            pixelRatio: 2
        },
        spritePath: '<%= dirs.root %>/images/sprite.png',
        stylesheetPath: '<%= dirs.css %>_sprites.scss'
    },
    taskOne: {
        src: [
            '<%= dirs.root %>/images/icons/*.png'
        ]
    },
    taskTwo: {
        src: [
            '<%= dirs.root %>/images/icons/blue/*.png'
        ]
    }
}
coveralls commented 9 years ago

Coverage Status

Coverage remained the same when pulling 0bedee41ee1026a7baa30c931a1ec94c94faf15a on scott-kennedy:allow-global-task-options into 375b918fc07a5f6aab2650ee9daf1d39455133aa on selaux:master.

selaux commented 9 years ago

Great :+1: , can you fix the code style issue then I can merge.

scott-kennedy commented 9 years ago

@selaux, updated the code styling to merge the two vars.

coveralls commented 9 years ago

Coverage Status

Coverage remained the same when pulling c0260f47a192277af62e79a0997fb4a731ba048b on scott-kennedy:allow-global-task-options into 375b918fc07a5f6aab2650ee9daf1d39455133aa on selaux:master.