plugin-scaffold
plugin-scaffold copied to clipboard
SVGs are cropped upon deployment
Describe the bug
When npm run build is run, SVGs have their "viewbox" attribute removed which causes cropping:

This is caused in plugin-scaffold/config/webpack.config.common.js. ImageminPlugin can be updated to this to correct it:
// Compress images
// Must happen after CopyWebpackPlugin
new ImageminPlugin({
disable: !isProduction,
test: settings.ImageminPlugin.test,
svgo: {
plugins: [
{
removeViewBox: false,
},
],
},
}),
Steps to Reproduce
- If you site has SVGs, run
npm run buildto see the cropping npm run watchdoes not include the cropping becauseImageminPluginis disabled on non-production environments,.
Expected behavior No cropping
Created a PR here: https://github.com/10up/plugin-scaffold/pull/131
This also applied to the theme scaffold, so I created a ticket over there too: https://github.com/10up/theme-scaffold/issues/206