broccoli-sprite
Advanced tools
Comparing version 0.0.2 to 0.0.3
18
index.js
@@ -35,3 +35,8 @@ var path = require('path'); | ||
return readTree(this.inTree).then(function (srcDir) { | ||
var files = self.options.src || []; | ||
var files = (self.options.src || []).map(function(file) { | ||
return srcDir+'/'+file; | ||
}); | ||
self.debugLog('srcDir', srcDir); | ||
self.debugLog('destDir', destDir); | ||
self.debugLog('files', files); | ||
var spritePath = path.join(destDir, self.options.spritePath); | ||
@@ -41,3 +46,3 @@ var stylesheetPath = path.join(destDir, self.options.stylesheetPath); | ||
mkdirp.sync(path.dirname(stylesheetPath)); | ||
var nsgOptions = self.options; | ||
var nsgOptions = JSON.parse(JSON.stringify(self.options)); //lazy way to deep clone | ||
nsgOptions.src = files; | ||
@@ -47,7 +52,6 @@ nsgOptions.spritePath = spritePath; | ||
self.debugLog('Options: ', nsgOptions); | ||
self.debugLog('spritePath', spritePath); | ||
self.debugLog('stylesheetPath', stylesheetPath); | ||
var promise = new rsvp.Promise(function(resolvePromise, rejectPromise) { | ||
nodeSpriteGenerator(nsgOptions, function (err) { | ||
self.debugLog('spritePath', spritePath); | ||
self.debugLog('stylesheetPath', stylesheetPath); | ||
nodeSpriteGenerator(nsgOptions, function (err) { | ||
if (!err) { | ||
@@ -63,3 +67,3 @@ self.debugLog('Sprite generated!'); | ||
}); | ||
return promise; | ||
return promise; | ||
}); | ||
@@ -66,0 +70,0 @@ }; |
{ | ||
"name": "broccoli-sprite", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"description": "Broccoli plugin that generates image sprites", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -13,4 +13,6 @@ # A broccoli plugin for sprite generation | ||
npm install broccoli-sprite | ||
In your project directory, run this command: | ||
npm install --save broccoli-sprite | ||
### Installation dependencies | ||
@@ -27,3 +29,3 @@ | ||
- [node canvas](https://github.com/LearnBoost/node-canvas/wiki "node canvas installation instructions") | ||
- Ensure that you have NodeJs v0.10.29 installed | ||
- Ensure that you have NodeJs version is v0.10.29 (>= v0.11.x will not work) | ||
- On Ubuntu: | ||
@@ -40,3 +42,3 @@ - `sudo apt-get install libcairo2-dev libjpeg8-dev libpango1.0-dev libgif-dev build-essential g++` | ||
src: [ | ||
'public/images/sprites/*.png' | ||
'images/sprites/*.png' | ||
], | ||
@@ -65,5 +67,10 @@ spritePath: 'assets/sprites.png', | ||
Ideally, however, the plugin *should be* integrated into | ||
`node_modules/ember-cli/lib/preprocessors.js`. | ||
However, currently, [this is not possible](https://github.com/stefanpenner/ember-cli/issues/810), | ||
until this `preprocessors.js` exposes its registry of BroccoliJs plugins. | ||
## Configuration Options | ||
`broccoli-sprite` warpas around the excellent | ||
`broccoli-sprite` wraps around the excellent | ||
[`node-sprite-generator`](https://github.com/selaux/node-sprite-generator) | ||
@@ -77,3 +84,3 @@ library. | ||
This is any broccoli tree. | ||
In an `ember-cli` app, this would most likely be `'public'`. | ||
In an `ember-cli` app, this would most likely be `"public"`. | ||
@@ -85,11 +92,12 @@ ### `options` | ||
There are a few things to note though: | ||
File paths, however, are not passed in verabtim, | ||
and are processed to enable them to work with BroccoliJs' trees. | ||
`src` is the full path, not the path within the tree. | ||
`src` is is an array of file paths specified relative to the input tree. | ||
Notice that in the example above, | ||
the tree is `'public'`, and "public" is repeated in the path within `src`. | ||
the tree is `'public'`, and "public" is **not** repeated in the paths within `src`. | ||
The same is **not** true for output paths though, | ||
The same is also true for output paths though, | ||
`spritePath` and `stylesheetPath`, | ||
which must be speicifed relative to the tree. | ||
which must be specified relative to the tree. | ||
Notice that "public" is not repeated within these paths. | ||
@@ -96,0 +104,0 @@ |
6343
63
102