Skip to content

Commit

Permalink
Added property - fixes #60
Browse files Browse the repository at this point in the history
  • Loading branch information
asciidisco committed Dec 3, 2014
1 parent a94982d commit cd81bec
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 2 deletions.
35 changes: 34 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 `<base href>`),
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
Expand All @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
5 changes: 5 additions & 0 deletions tasks/sprites.js
Original file line number Diff line number Diff line change
Expand Up @@ -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, "/");
}
Expand Down

0 comments on commit cd81bec

Please # to comment.