[DEPRECATED] img-svg-inline-loader
Webpack loader used for inline replacement of SVG reference in src attribute of img tags with actual content of SVG file.
Loader has built-in SVGO support for SVG optimization.
Install
npm install img-svg-inline-loader --save-dev
Usage
In webpack config:
test: /\.html$/ use: loader: "img-svg-inline-loader" options: /* ... */ // ...
In code:
Which replaces into:
Configuration
Default options:
keyword: "svg-inline" strict: true xhtml: false svgo: plugins: cleanupAttrs: true // ...
Explanation:
-
keyword
Defines keyword, which marks img tags you want to inline replace with SVG. Keyword has to be wrapped with whitespace characters (e.g. space). In case of some conflicts, you can also use data version of your keyword (e.g.data-keyword
). -
strict
In strict mode loader replaces only img tags with defined keyword. If strict mode is disabled, loader replaces all img tags. -
xhtml
In XHTML mode attribute minimization is forbidden. Empty attributes are filled with their names to be XHTML-compliant (e.g.disabled="disabled"
). -
svgo
SVGO documentation can be found here. If you do not want use SVGO, set it tonull
.
Notes: User-defined options are not deep-merged with default options.