Change asset paths inside css files based on output from grunt-filerev, grunt-hashmap, or other similar plugins
Change asset paths inside css files based on output from grunt-filerev
This plugin requires Grunt
If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:
npm install grunt-cssurlrev --save-dev
This plugin will take css files and modify url links inside them (in place) that point to versioned assets versioned either with
grunt.filerev or from a specified json file. Please note that it modifies files in place at present.
In your project's Gruntfile, add a section named
cssurlrev to the data object passed into
gruntinitConfigcssurlrev:options:assets: 'path/to/assets.json'your_target:src: 'public/css/*.css'
A file path that is used to load a json object from. If empty (default), then
grunt.filerev.summary is used to modify url paths.
In this example, files matching
public/css/*.css are modified to have any links to assets modified with
gruntinitConfigcssurlrev:options:separator: ': 'punctuation: ' !!!'files:src: 'public/css/*.css'
In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using Grunt.