Embed URL's as base64 strings inside your stylesheets
Embed URLs as base64 data URIs 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.
This plugin requires Grunt
~0.4.0 and Python
2.7, since it depends on node-gyp.
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
Task targets, files and options may be specified according to the grunt Configuring tasks guide.
Both image and font URLs are supported. Remote (
https) URLs are supported as well.
. or the directory of
The base directory for URLs. Can be absolute or relative to the directory of your
Will the script terminate if the file referenced by the URL is missing or the request to get it failed?
When set to
false a warning will be produced for each missing file or failed request.
Default: No restrictions
Skip URLs that are larger than the specified value.
Specifies the mode of embedding.
true(inclusive) means that you have to manually mark each URL that needs to be embedded using the
/* embed */comment.
false(exclusive) means that every URL is embedded, except those that are marked with
/* noembed */comment.
Should we try to use the
mmmagic MIME-type sniffing library or should we always determine MIME-type only from the extension of the URL?
When set to
false the extension checking is always used. When set to
true it will first try use the
mmmagic library. However, in case the library failed to install it will fallback to extension checking.
cssUrlEmbed:encodeWithBaseDir:options:baseDir: './app'files:'path/to/output.css': 'path/to/input.css'
cssUrlEmbed:encode:expand: truecwd: 'target/css'src: '**/*.css'dest: 'target/css'
cssUrlEmbed:encode:options:skipUrlsLargerThan: '5 MB'expand: truecwd: 'target/css'src: '**/*.css'dest: 'target/css'
cssUrlEmbed:encode:options:useMimeTypeSniffing: falseexpand: truecwd: 'target/css'src: '**/*.css'dest: 'target/css'
inclusiveoption. See docs.
falseto disable this.