From 996eff82b0bd11976daf997c69e12dcdcd643683 Mon Sep 17 00:00:00 2001 From: Justin Ridgewell Date: Wed, 5 Feb 2014 17:33:43 -0500 Subject: [PATCH] fix(build): rewrite relative CSS URLs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix useminPrepare task to rewrite relative CSS urls First, tell useminPrepare to only 'cssmin' our CSS files (dropping the concat task). See https://github.com/yeoman/grunt-usemin/issues/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'); } ``` --- templates/common/Gruntfile.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/templates/common/Gruntfile.js b/templates/common/Gruntfile.js index 24ddf260f..c36416ae2 100644 --- a/templates/common/Gruntfile.js +++ b/templates/common/Gruntfile.js @@ -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: {} + } + } } }, @@ -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: [{