Skip to content

MikAleinik/svg-loader-js

Repository files navigation

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

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published