sprity / grunt-sprity

Grunt task for generating css sprites and corresponding stylesheets.
MIT License
2 stars 1 forks source link

grunt-sprity

NPM version Build Status Dependencies

Grunt task for generating css sprites and corresponding stylesheets with sprity.

Getting Started

This plugin requires Grunt ~0.4.5

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-sprity --save-dev

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

grunt.loadNpmTasks('grunt-sprity');

The "sprity" task

Overview

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

module.exports = function(grunt) {

  // Project configuration.
  grunt.initConfig({
    sprity: {
      options: {
        'cssPath': '../images',
        'processor': 'css',
        'orientation': 'vertical',
        'margin': 4
      },
      sprite: {
        options: {
          'style': 'dest/css/sprite.css'
        },
        src: ['src/images/*', 'src/images2/*'],
        dest: 'dest/images/sprite.png',
      },
      base64: {
        options: {
          'base64': true
        },
        src: ['src/images/*'],
        dest: 'dest/scss/base64.css',
      }
    }
  });

  // Load the plugin that provides the "sprity" task.
  grunt.loadNpmTasks('sprity');

  // Default task(s).
  grunt.registerTask('default', ['sprity']);
};

Options

More

See sprity documentation