Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslnode 18–226 runs
build_error
glibcnode 18–226 runs
build_error
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
Loader
✓ module.exports = { module: { rules: [ { test: /\.svg$/, loader: 'svgo-loader', options: { ... } } ] } }
✗ import svgoLoader from 'svgo-loader'
This is a webpack loader, not a JavaScript module. It is used via webpack configuration, not imported in source code.
Plugin
✓ No plugin import needed. Use as loader in webpack config.
There is no JavaScript import available. The loader is referenced by string in webpack config rules.
Config
✓ Use svgo.config.js file or pass options directly in webpack config.
✗ const config = require('svgo-loader/config.js')
SVGO configuration is external, not provided by svgo-loader package.
Basic webpack configuration to optimize SVGs with SVGO, disabling external config and providing inline plugin list and options.
// webpack.config.js
module.exports = {
module: {
rules: [
{
test: /\.svg$/,
type: 'asset',
loader: 'svgo-loader',
options: {
configFile: false, // disable external config
multipass: true,
js2svg: { indent: 2, pretty: true },
plugins: [
'removeDoctype',
'removeXMLProcInst',
'removeComments',
'removeMetadata',
'removeEditorsNSData',
'cleanupAttrs',
'inlineStyles',
'minifyStyles',
'convertStyleToAttrs',
'cleanupIDs',
'removeRasterImages',
'removeUselessDefs',
'cleanupNumericValues',
'convertColors',
'removeUnknownsAndDefaults',
'removeNonInheritableGroupAttrs',
'removeUselessStrokeAndFill',
'removeViewBox',
'cleanupEnableBackground',
'removeHiddenElems',
'removeEmptyText',
'convertShapeToPath',
'convertEllipseToCircle',
'moveElemsAttrsToGroup',
'moveGroupAttrsToElems',
'collapseGroups',
'convertPathData',
'convertTransform',
'removeEmptyAttrs',
'removeEmptyContainers',
'mergePaths',
'removeUnusedNS',
'sortAttrs',
'sortDefsChildren',
'removeTitle',
'removeDesc',
'removeDimensions',
'removeAttrs',
'removeElementsByAttr',
'addClassesToSVGElement',
'addAttributesToSVGElement',
'removeOffCanvasPaths',
'removeStyleElement',
'removeScriptElement',
'reusePaths'
]
}
}
]
}
};
Errors
Common errors & fixes
Module not found: Error: Can't resolve 'svgo'
svgo is a peer dependency not automatically installed.
fixRun 'npm install svgo --save-dev' or 'yarn add svgo -D'.
Error: SVGO config not found at /path/to/svgo.config.js
Loader searches for svgo.config.js by default but file missing.
fixSet configFile: false in loader options to disable default config loading.
Error: Rule can only have one source, but found more than one (asset, svgo-loader)
Conflict when both 'type: asset' and 'loader' are used improperly.
fixEnsure rule has only one type property (e.g., 'type: asset') and 'loader' specified.
Audit
Dependencies
svgorequiredPeer dependency - SVGO is the core optimization library. Must be installed separately.
webpackrequiredPeer dependency - requires webpack to function.