Skip to content
This repository has been archived by the owner on Mar 26, 2018. It is now read-only.

Commit

Permalink
fix(build): rewrite relative CSS URLs
Browse files Browse the repository at this point in the history
Fix useminPrepare task to rewrite relative CSS urls

First, tell useminPrepare to only 'cssmin' our CSS files (dropping the
concat task). See yeoman/grunt-usemin#225.
Second, tell cssmin to rewrite relative urls to be relative to our app
directory.

This is particularly useful for bower install components that have CSS
files that reference relative urls. ie.

```
.
├── app
│   └── bower_components
│       └── component
│           ├── images
│           │   └── image.png
│           └── style.css
└── build
```

```
body {
background: url('images/image.png');
}
```

Will have now properly rewrite it's image url to
```
body {
background: url('bower_components/component/images/image.png');
}
```
  • Loading branch information
Justin Ridgewell authored and passy committed Feb 10, 2014
1 parent 023da9d commit 996eff8
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion templates/common/Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,16 @@ module.exports = function (grunt) {
useminPrepare: {
html: '<%%= yeoman.app %>/index.html',
options: {
dest: '<%%= yeoman.dist %>'
dest: '<%%= yeoman.dist %>',
flow: {
html: {
steps: {
js: ['concat', 'uglifyjs'],
css: ['cssmin']
},
post: {}
}
}
}
},

Expand All @@ -251,6 +260,11 @@ module.exports = function (grunt) {
},

// The following *-min tasks produce minified files in the dist folder
cssmin: {
options: {
root: '<%%= yeoman.app %>'
}
},
imagemin: {
dist: {
files: [{
Expand Down

0 comments on commit 996eff8

Please sign in to comment.