npm install -g svgo
svgo.config.js
module.exports = {
multipass: true,
plugins: [
{
name: 'inlineStyles',
params: {
onlyMatchedOnce: false, // make sure all styles are inlined
},
},
{
name: 'convertStyleToAttrs',
},
{
name: 'removeViewBox',
active: false, // keep viewBox if you want to retain responsiveness
},
{
name: 'removeUnknownsAndDefaults',
active: false, // keep defaults just in case
},
],
};mkdir -p inlined && for f in *.svg; do svgo --config svgo.config.js -i "$f" -o "inlined/${f%.svg}_inlined.svg"; done
files will appear in ./inlined