1.2.1 • Published 2 years ago
svg-to-json-webpack-plugin v1.2.1
SVG to JSON Webpack Plugin
This webpack plugin generates a collection of SVGs in JSON format from all .svg
files in a directory. This strips out the svg and title tags for manually addition when loading the SVG data. In addition to the SVG data, it also returns each SVG's title and viewbox. This code is heavily based on the SVG Spritemap Webpack Plugin by Freshheads.
NPM: svg-to-json-webpack-plugin
Installation
npm install svg-to-json-webpack-plugin --save-dev
Usage
// webpack.config.js
var SvgToJsonPlugin = require('svg-to-json-webpack-plugin');
module.exports = {
// ...
plugins: [
new SvgToJsonPlugin({
// Optional options object
})
]
}
Options
Option | Default | Description |
---|---|---|
src | '**/*.svg' | glob used for finding the SVGs that should be in the spritemap |
glob | {} | Options object for glob |
prefix | 'sprite-' | Prefix added to sprite identifier in the spritemap |
filename | 'spritemap.json' | Name for the generated file (located at the webpack output.path ), [hash] and [contenthash] are supported |
chunk | 'spritemap' | Name of the generated chunk |
deleteChunk | true | Deletes the chunked file chunk after packing is complete |