This is a simple loader for including SVG vector images in your JS code.
npm install -D svg-loader-js
In webpack config specify
module: {
rules: [
{
test: /\.(svg)$/i,
use: "svg-loader-js"
},
],
},
When using TypeScript add a module definition to your index.d.ts file
declare module "*.svg"
Import svg in your module:
import icon from './icon.svg';
and use a ready to place svg element:
const button = document.createElement("button");
button.append(icon);
Loader has no additional options.
This loader does not support loading an svg file with several icons separated by id