simple-svg-loader

var webpack = require('webpack');

Usage no npm install needed!

<script type="module">
  import simpleSvgLoader from 'https://cdn.skypack.dev/simple-svg-loader';
</script>

README

simple-svg-loader

config:

var webpack = require('webpack');

module.exports = {
    module: {
        rules: [
            {
                test: /\.svg$/,
                loader: 'simple-svg-loader'
            }
        ]
    }
};

use:

import './icons/home.svg';
<a href="/">
    <svg viewBox="0 0 32 32"><use xlink:href="#home"></use></svg>
    Home
</a>

change id:

import './icons/home.svg?id=icon-home';
<svg viewBox="0 0 32 32"><use xlink:href="#icon-home"></use></svg>