Skip to content

bevacqua/spritesmith-cli

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

spritesmith-cli

Adds a CLI to the spritesmith module

Spritesmith is awesome but sometimes we don't want to run it through Grunt.

Install

npm install -D spritesmith-cli

Usage

spritesmith [options]

These are the options you can set on the CLI.

Option Description
--rc Point to a different .spritesmith.js configuration file

The default configuration file used will be .spritesmith.js at the current working directory (process.cwd()). This file should export a few properties. Note that you can export either a single object or an array. If you use an array you'll be able to create multiple spritesheets in one shot.

Examples:

'use strict';

var util = require('util');

module.exports = {
  src: './client/img/icons/**/*.{png,gif,jpg}',
  destImage: '.bin/public/img/icons.png',
  destCSS: 'client/css/generated/icons.css',
  imgPath: '/img/icons.png',
  padding: 2,
  algorithm: 'top-down',
  algorithmOpts: { sort: false },
  engine: 'gmsmith',
  cssOpts: {
    cssClass: function (item) {
      return util.format('.ic-%s:before', item.name);
    }
  }
};
'use strict';

var util = require('util');

module.exports = [{
  src: './client/img/icons/**/*.{png,gif,jpg}',
  destImage: '.bin/public/img/icons.png',
  destCSS: 'client/css/generated/icons.css',
  imgPath: '/img/icons.png',
  cssOpts: {
    cssClass: function (item) {
      return util.format('.ic-%s:before', item.name);
    }
  }
}, {
  src: './client/img/markdown-editor/**/*.{png,gif,jpg}',
  destImage: '.bin/public/img/markdown-editor.png',
  destCSS: 'client/css/generated/markdown-editor.styl',
  imgPath: '/img/markdown-editor.png',
  cssOpts: {
    cssClass: function (item) {
      return util.format('.pm-%s:before', item.name);
    }
  }
}];

Note that src can be either a globbing pattern or an array of globbing patterns, it'll be passed straight to multi-glob.

The destImage and destCSS properties are optional and can be omitted. That means that you can create only one file depending on your needs.

That's about it. For configuration information please refer to the grunt-spritesmith and spritesmith packages.

License

MIT

About

😳 Adds a CLI to the spritesmith module

Resources

License

Stars

Watchers

Forks

Packages

No packages published