Package Exports
- @constgen/neutrino-svg-loader
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@constgen/neutrino-svg-loader) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
@constgen/neutrino-svg-loader
Neutrino middleware for SVG files.
Features
- Automatically exclude
.svgextension fromimagerule if present - Enable usage of query parameters in SVG paths for compilation time image processing (e.g.
image.svg?fill=currentColor) with svg-transform-loader - Encode SVGs to DataURI *without- encoding to Base64 when imported from JS or Components with svg-url-loader
- SVG elements
idattributes are extended with unique prefixes to avoid collisions between inlined<svg>images.
Requirements
- Node.js v10+
- Neutrino v9
- Webpack v4
Installation
@constgen/neutrino-svg-loader can be installed from NPM. You should install it to "dependencies" (--save) or "devDependncies" (--save-dev) depending on your goal.
npm install --save @constgen/neutrino-svg-loaderUsage
In preset
Require this package and plug it into Neutrino. The following shows how you can pass an options object to the middleware, showing the defaults:
let svgLoader = require('@constgen/neutrino-svg-loader')
neutrino.use(svgLoader({
limit: 10000 // 10 KB - images lesser than this size in bytes will be inlined into JS bundle. But onlly images referenced from styles are affected. All others are alwas inlined
}))In neutrinorc
The middleware also may be used together with another presets in Neutrino rc-file, e.g.:
.neutrinorc.js
let svgLoader = require('@constgen/neutrino-svg-loader')
module.exports = {
use: [
svgLoader()
]
}