From cd81beca3e4694cc7c57822668bc19bb8a493294 Mon Sep 17 00:00:00 2001 From: Sebastian Golasch Date: Wed, 3 Dec 2014 17:46:22 +0100 Subject: [PATCH] Added property - fixes #60 --- README.md | 35 ++++++++++++++++++++++++++++++++++- package.json | 2 +- tasks/sprites.js | 5 +++++ 3 files changed, 40 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 6625ee0..c59cbc7 100644 --- a/README.md +++ b/README.md @@ -192,7 +192,6 @@ the generated css file would look like this: .MyImage2 { background-position: 0 -396px; } - ``` This task doesn´t depend on any external libraries, except for @@ -326,6 +325,37 @@ would generate something like this: } ``` +If you want to set a specific (static) CSS output path (maybe because you´re fiddling around with your ``), +you can do so by extending the config with a `staticImagePath` like so: + +```javascript + sprites: { + icons36: { + src: ['src/img/icons36/*.png'], + css: 'src/css/icons36.css', + map: 'src/img/icons36.png', + staticImagePath: 'public/img/' + } + } +``` + +The output would look like the following: + +```css +.MyImage1, .Icon-MyImage2 { + background: url("public/img/icon36.png") no-repeat; +} + +.MyImage1 { + background-position: 0 -432px; +} + +.MyImage2 { + background-position: 0 -396px; +} + +``` + ## Future (TODO) * Better documentation (Near future!) * JS only PNG optimizing @@ -335,6 +365,9 @@ would generate something like this: ## Release History +### 0.3.5 ++ added `staticImagePath` described in [#60](https://github.com/asciidisco/grunt-imagine/issues/60) + ### 0.3.42 + bump dependencies [@alpadev] (https://github.com/alpadev) diff --git a/package.json b/package.json index 1266400..642831c 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "grunt-imagine", "description": "Grunt tasks for optimizing, inlining & spriting images", - "version": "0.3.42", + "version": "0.3.5", "homepage": "http://asciidisco.github.com/grunt-imagine/", "author": { "name": "asciidisco", diff --git a/tasks/sprites.js b/tasks/sprites.js index 36ec999..fbcdd73 100644 --- a/tasks/sprites.js +++ b/tasks/sprites.js @@ -48,6 +48,11 @@ module.exports = function(grunt) { function generateBackgroundImagePath () { var imagePath = path.relative(path.dirname(cssFile), spriteMap); + // check if the user registered a static path for images in the config + if (this.data.staticImagePath) { + imagePath = this.data.staticImagePath; + } + if (path.sep === "\\"){ imagePath = imagePath.replace(/\\/g, "/"); }