grunt-img-to-inlinesvg
v0.1.5
Published
Replace svg images with inline svg during grunt build process
Downloads
3
Readme
grunt-img-to-inlinesvg
Replace svg images with inline svg during grunt build process
Getting Started
This plugin requires Grunt ~0.4.5
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-img-to-inlinesvg --save-dev
Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:
grunt.loadNpmTasks('grunt-img-to-inlinesvg');
Attention !!!
Plugin only replace content and does not care about optimalization of svg icons. You have to optimize svg before to inline them. Use SVGO plugin.
The "img_to_inlinesvg" task
Overview
In your project's Gruntfile, add a section named img_to_inlinesvg
to the data object passed into grunt.initConfig()
.
grunt.initConfig({
img_to_inlinesvg: {
options: {
// Task-specific options go here.
},
your_target: {
// Target-specific file lists and/or options go here.
},
},
});
Options
options.svgFileLimit
Type: Number
Default value: 10
A number value that is used to limit svg file size. If file size will be bigger than this limit, image will be skipped and will not be inlined.
options.assetsDir
Type: String
Default value: ``
If you will use absolute path /path/to/image.svg
you can specify directory to replace /
to options.assetsDir
.
options.selector
Type: String
Default value: img[inline]
CSS selector of images to process inline SVG insertion.
Usage Examples
grunt.initConfig({
img_to_inlinesvg: {
options: {
svgFileLimit: 10,
assetsDir: "",
selector: "img[inline]"
},
files: {
'dest/index.html': ['src/index.html'],
},
},
});
Contributing
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.
Release History
(Nothing yet)