0.0.7 • Published 11 years ago

grunt-montage v0.0.7

Weekly downloads
1
License
-
Repository
github
Last release
11 years ago

montage

Generate CSS sprite sheets and the corresponding stylesheet

Getting Started

This plugin requires Grunt 0.4 or later and depends upon the montage command line tool bundled with ImageMagick. If you don't already have it (and you're running on *nix/Mac OS), it will be automatically installed.

If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:

npm install grunt-montage --save-dev

Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:

grunt.loadNpmTasks("grunt-montage");

The "montage" task

Overview

In your project's Gruntfile, add a section named montage to the data object passed into grunt.initConfig().

grunt.initConfig({
    montage: {
        targetName: {
            // Target-specific montage configuration
        }
    }
});

Options

options.size

Type: Number Default value: 16

The width/height of each image included in the sprite sheet.

options.prefix

Type: String Default value: ".montage"

A CSS selector to prefix all sprite classes with.

options.outputImage

Type: String Default value: "montage.png"

The name of the generated sprite sheet image.

options.outputStylesheet

Type: String Default value: "montage.css"

The name of the generated stylesheet.

Usage Examples

Default Options

In this example, the default options are used to do generate a sprite sheet from 16x16 pixel versions of all the .png files in the images/icons directory. The sprite sheet will be created at assets/sprites/montage.css and the image at assets/sprites/montage.png, based on the default option values listed above.

grunt.initConfig({
    montage: {
        simple: {
            files: {
                "assets/sprites": [
                    "images/icons/*.png"
                ]
            }
        }
    }
});

Custom Options

In this example, custom options are used to configure the output. It will generate a sprite sheet of 32x32 pixel images at assets/sprites/sprites.png and the corresponding stylesheet at assets/sprites/styles.css.

grunt.initConfig({
    montage: {
        simple: {
            files: {
                "assets/sprites": [
                    "images/icons/*.png"
                ]
            },
            options: {
                size: 32,
                outputImage: "sprites.png",
                outputStylesheet: "styles.css"
            }
        }
    }
});

Contributing

In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using Grunt.

0.0.7

11 years ago

0.0.6

11 years ago

0.0.5

11 years ago

0.0.4

11 years ago

0.0.3

11 years ago

0.0.2

11 years ago

0.0.1

11 years ago