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 = ; exportsdefault entry: //..., output: //..., plugins: 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:
<!--Add background-image to ::after--><!--Add background-image to ::before-->
and CSS variable: