css-svg-sprite-webpack-plugin

1.0.3 • Public • Published

css-svg-sprite-webpack-plugin

Generate CSS sprite from directory with SVG files.

npm i css-svg-sprite-webpack-plugin

webpack.config.js

const CssSvgSpriteWebpackPlugin = require('css-svg-sprite-webpack-plugin');
 
exports.default {
    entry: //...,
    output: //...,
    plugins: [
        new CssSvgSpriteWebpackPlugin({
            fileName: 'sprite.css',
            dir: 'svg-directory',
            injected: true //add <link> to index.html
        })
    ];
}

Usage example 🙂

filename - is name of SVG file. You can use this class names:

<div class="icon-filename"></div>
<div class="icon-filename__after"><!--Add background-image to ::after--></div>
<div class="icon-filename__before"><!--Add background-image to ::before--></div>

and CSS variable:

div {
    background: var(--icon-filename) no-repeat center / contain;
}

Package Sidebar

Install

npm i css-svg-sprite-webpack-plugin

Weekly Downloads

1

Version

1.0.3

License

ISC

Unpacked Size

3.58 kB

Total Files

3

Last publish

Collaborators

  • alexpalchikovskiy