svg-snabbdom-loader
v1.0.0
Published
Webpack svg-files to snabbdom vdom loader
Downloads
1
Maintainers
Readme
svg-snabbdom-loader
Webpack svg to snabbdom vnode loader
Installation
$ npm install --save-dev svg-snabbdom-loader
Parameters
Loader supports following parameters:
omitFill
used to omitfill
attribute from generated VNode attributes (defaults to keepfill
attribute as is)omitKey
used to omitkey
attribute from generated top-level svg VNode attributes (generated key defaults tosvg-{basename}
where{basename}
is filename without.svg
extension)className
used to setclass
attribute for generated top-level svg VNode (defaults tosvg-icon
)
Usage
Specify in webpack.config.js
:
module.exports = {
//...
module: {
loaders: [{
test: /\.svg$/,
loader: 'svg-snabbdom-loader'
}]
},
//...
};
Chained with svgo-loader:
module.exports = {
//...
module: {
loaders: [{
test: /\.svg$/,
loader: 'svg-snabbdom-loader!svgo-loader'
}]
},
//...
};
With parameters:
module.exports = {
//...
module: {
loaders: [{
test: /\.svg$/,
loader: 'svg-snabbdom-loader?omitFill=true&className=svg-icon-large!svgo-loader'
}]
},
//...
};
Splitting filled and non-filled graphics:
module.exports = {
//...
module: {
loaders: [{
test: /\.svg$/,
include: /src\/svg\/filled/
loader: 'svg-snabbdom-loader?className=svg-filled!svgo-loader'
}, {
test: /\.svg$/,
include: /src\/svg\/nonfilled/
loader: 'svg-snabbdom-loader?className=svg-non-filled!svgo-loader'
}]
},
//...
};
License
MIT, see LICENSE.md for details.