Embed URL's as base64 data URI's inside your stylesheets
There are lots of base64 embedding Grunt plugins out there, but pretty much all of them are already outdated and/or abandoned. This plugin aims to change that.
Most of the codebase is donated from datauri plugin.
This plugin requires Grunt ~0.4.0
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-css-url-embed --save-dev
Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:
grunt.loadNpmTasks('grunt-css-url-embed');
Run this task with the grunt cssUrlEmbed
command.
Task targets, files and options may be specified according to the grunt Configuring tasks guide.
Both image and font URL's are supported. Web URL's won't be supported.
Type: String
Default: .
or the directory of Gruntfile.js
The base directory for URL's. Can be absolute or relative to the directory of your Gruntfile.js
.
cssUrlEmbed: {
encodeDirectly: {
files: {
'path/to/output.css': ['path/to/input.css']
}
}
}
cssUrlEmbed: {
encodeWithBaseDir: {
options: {
baseDir: './app'
},
files: {
'path/to/output.css': ['path/to/input.css']
}
}
}
cssUrlEmbed: {
encode: {
expand: true,
cwd: 'target/css',
src: [ '**/*.css' ],
dest: 'target/css'
}
}
cssUrlEmbed: {
options: {
excludeUrlExtensions: [ 'php' ]
},
encode: {
expand: true,
cwd: 'target/css',
src: [ '**/*.css' ],
dest: 'target/css'
}
}
- 2014-05-14 v0.1.4 Added option to exclude certain file extensions.
- 2014-01-29 v0.1.3 Fixed handling of URL's with parameters. Improved logging.
- 2013-10-02 v0.1.2 Changed logging a bit.
- 2013-09-17 v0.1.1 Removed dependency on datauri. Now pretty much all MIME types are supported.
- 2013-09-09 v0.1.0 First version.