grunt-data-uri
This is gruntplugin task.
Convert to data-uri from image path
Getting Started
Install from npm.
% npm i -D grunt-data-uri
Add your project's Gruntfile.js
.
grunt;
Example
Config
grunt
For traversal image files. If options.baseDir
is specified, use baseDir
instead of src css exsting dir. That's useful when image paths in your css are absolute.
sample/css/raw/main.css
Before This file is raw css.
Execute
Execute grunt-data-uri
% grunt dataUri
Running "dataUri:dist" (dataUri) task
SRC: 3 file uri found on sample/css/raw/main.css
>> Encode: ../../img/embed/will_encode.jpeg
>> Skipping (size 24875 > 10240): ../../img/embed/not_encode.jpeg
>> Adjust: ../../img/not_encode.png -> ../img/not_encode.png
>> => path/to/project/sample/css/main.css
Done, without errors.
sample/css/main.css
After This file is processed and output css.
/* encoded to data-uri(base64) *//* not encoded too large image *//* not encoded but adjust relative path! */
Tests
npm install
npm test
Changelog
- 0.3.0
- Update
data-uri
module - Remove query and hash fragment from url
- Update
- 0.2.0
- Add
maxBytes
option - fix
fixDirLevel
bug
- Add
- 0.1.0
- Add
baseDir
option
- Add
- 0.0.2
- Add
datauri
module
- Add
- 0.0.1
- first commit
License
MIT