Grunt CSS Url Rewrite
This task provides a way to rewrite all URL's found within a stylesheet (those within a url( ... ) declaration), to improve cache-invalidation or to reference a CDN or something like that.
Install this plugin with the command:
npm install grunt-css-url-rewrite
Next, add this line to your project's grunt file:
Lastly, add configuration settings to your grunt.js file (see below).
This task has two required properties,
src is the path to your stylesheet and
dest is the file this task will write to (relative to the grunt.js file). If this file already exists it will be overwritten.
An example configuration looks like this:
/* styles.css */
/* output.css */
Optional Configuration Properties
CssUrlRewrite can be customized by specifying the following options:
baseDir: If you have absolute image paths in your stylesheet, the path specified in this option will be used as the base directory.
stripParameters: Remove querystring-parameters from url's.
skipExternal: Skip external url's. Rewriting external url's doesn't always work yet, so this could be necessary for good results.
parallel: true to execute the rewrite asynchronously for each file. Default value is true.
Specify that an image should be skipped by adding the following querystring after the image:
This plugin is compatible with Grunt 0.4.x.
Copyright (c) 2014 Jasper Haggenburg (@jpunt) Licensed under the MIT License.