Manage revisions in CSS urls.
This plugin requires Grunt ~0.4.1
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-urlrevs
One the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:
grunt.loadNpmTasks('grunt-urlrevs');
Builds image revisions tree, finds CSS files and replaces each occurences of links to images in url()
directives.
In your project's Gruntfile, add a section named urlrevs
to the data object passed into grunt.initConfig()
.
grunt.initConfig({
urlrevs: {
some_target: {
options: {
// Target-specific options go here.
},
src: [
// Specify the files you want to edit
]
}
}
})
Each target defines a specific task that can be run.
Type: Integer
Default value: 6
The length of the revision.
Type: String
Default value: HEAD
Traversed branch.
Type: RegExp
Default value: \\.(png|jpg|jpeg|gif)
Regular expression to filter files in stage of building revisions tree and replacing revisions in urls.
Type: String
Default value: root
Prefix to cut when generate absulute image url.
Type: String
Default value: root/i
Path to search files in stage of building tree. Relative to repository root directory.
Type: Array
Default value: [ '^\\/' ]
All valid URL masks represented as a list of RexExp
-like strings.
Type: Array
Default value: [ '^https?:\\/\\/', '^\\/\\/', '^data:image\\/(sv|pn)g', '^%23' ]
Defined URL masks which should be excluded during processing. Represented as a list of RexExp
-like strings.
Type: Boolean
Default value: true
Use uppercased revision string like F96A722
.
Type: Boolean
Default value: true
Allows embed revision into filename, e.g. /i/navigation_sprite.F96A722.png
.
Type: Boolean
Default value: true
Fixes uncommited changes in the repository. All new files will be added to the repository. As a commit message it uses
value of options.message
.
Type: String
Default value: Wave a magic wand (by urlrevs)
Message used at autocommit stage.
grunt.initConfig({
urlrevs: {
live: {
options: {
abbrev: 6,
branch: 'HEAD',
filter: '\\.(png|jpg|jpeg|gif|bmp)',
prefix: 'root',
path: 'root/i',
valid: [ '^\\/', '^https?:\\/\\/' ],
skip: [ '^https?:\\/\\/' ],
upcased: true,
implant: false
},
src: [
'root/css/**/*.css'
]
}
},
});
grunt.loadNpmTasks('grunt-urlrevs');
grunt.registerTask('default', ['urlrevs:live']);
grunt-urlrevs is licensed under the MIT license.