MikAleinik / svg-loader-js

Simple SVG loader for WebPack

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

This is a simple loader for including SVG vector images in your JS code.

Install from NPM

npm install -D svg-loader-js

Settings

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"

Usage in code

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);

Options

Loader has no additional options.

Description

This loader does not support loading an svg file with several icons separated by id

About

Simple SVG loader for WebPack

License:MIT License


Languages

Language:JavaScript 100.0%