Skip to content

Generates SVG spritemap in JSON format from all SGVs in a directory

License

Notifications You must be signed in to change notification settings

gilesa/svg-to-json-webpack-plugin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

License

This project is licensed under the MIT license.

About

Generates SVG spritemap in JSON format from all SGVs in a directory

Resources

License

Stars

Watchers

Forks

Packages

No packages published