svg-element-loader
v0.2.0
Published
Load svg images as DOM Elements with webpack
Downloads
4
Readme
svg-element-loader
Load svg images as DOM Elements with webpack
Installation
npm install --save-dev svg-element-loader
webpack.config
module.export = {
module: {
rules: [
{
test: /\.svg$/i,
loader: 'svg-element-loader'
}
]
}
};
tsconfig.json
{
"include": ["node_modules/svg-element-loader/*.d.ts"]
}
Usage
In JavaScript
import playIcon from 'assets/play-icon.svg';
document.body.appendChild(playIcon);
Element properties and methods are available. For example:
playIcon.classList.add('emphasize');
const circle = playIcon.querySelector('circle[stroke="#fff"]');
circle.style.stroke = '#333';'