sprity-dirs
Apply sprity to multiple directories and generate seperate sprite and css for each directory.
Example
var sprityDir = ; ;
var sprityDir = ;var opts = to: 'build'; ;;
var sprityDir = ;var path = ;;
⌘ tree src/
src/
├── delivery
│ ├── address_36.png
│ ├── mobile_36.png
│ ├── taketime_36.png
│ └── user_36.png
└── icon
├── cart_36.png
├── category_36.png
├── checked_40.png
├── close_30.png
├── disable_40.png
├── failure_66.png
├── message_30.png
├── success_66.png
└── unchecked_40.png
output:
⌘ tree build/
build/
├── delivery
│ ├── delivery.png
│ └── index.css
└── icon
├── icon.png
└── index.css
Api Usage
sprityDir(dirPattern, opts)
Returns a promise.
dirPattern
Type: String
, Array
Pattern used by xglob to locate the directories, each corresponding to a sprite with all pics in it. Actually, anything that matches the pattern but not a directory will be ignored.
opts
Type: Function
, Object
, String
When Function
, it receives the dir path, and should return a sprity option object to generate the sprite. No need to specify src
.
When String
, it indicates the directory where all the output sprites directories lie.
When Object
, it should be sprity option common for all sprites, with the following default values:
out
. For each sprite, it will bepath.resolve(options.to, dirName)
prefix
.sp-{dirName}
style
../index.css
name
.{dirname}
cssPath
..
Command Line Usage
Right now you can only specify the source directories and the output root.
npm i sprity-dirs -gsprity-dirs src/* build