Skip to content

fix(build): production SVGO for SVG assets and stable icon sprites - #522

Merged
cedric07 merged 6 commits into
masterfrom
fix/svgo-minimizer-svg-filter
Oct 20, 2026
Merged

cedric07 merged 6 commits into
masterfrom
fix/svgo-minimizer-svg-filter

Conversation

@cedric07

@cedric07 cedric07 commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Restrict ImageMinimizerPlugin.svgoMinify to .svg files in production (same idea as the Sharp filter that excludes SVGs).
  • Remove prefixIds from config/svgo.config.js so sprite symbol IDs stay #icon-{slug} for PHP/markup <use href="…"> (aligned with beapi-blocks-theme#1fbf1ac).
  • Skip production SVGO on extracted sprite sheets under dist/icons/*.svg (svg-sprite-loader); prod SVGO on merged sprites collapses <symbol> entries. Source icons are still optimized via svgo-loader at compile time.

Test plan

  • yarn build completes without image minimizer errors
  • Raster images under src/img are still optimized via Sharp in dist/
  • Standalone SVGs in dist/images/ (or equivalent) are still optimized via SVGO
  • dist/icons/sprite.svg and dist/icons/social.svg keep all id="icon-*" symbols
  • Icons render on the front (/dist/icons/{sprite}.svg#icon-…)

Note

Low Risk
Build-time asset pipeline only; no runtime auth or data handling, with behavior aligned to existing compile-time svgo-loader for source icons.

Overview
Fixes production image optimization so standalone SVGs get SVGO while icon sprite sheets stay intact and <use href="#icon-*"> keeps working.

Production ImageMinimizerPlugin now excludes paths under icons/ (merged sprites from svg-sprite-loader), because a second SVGO pass on those files was collapsing <symbol> entries. SVGO minification is limited to .svg files via a filter, mirroring the existing Sharp path that skips SVGs.

prefixIds is removed from config/svgo.config.js so symbol IDs stay as #icon-{slug} instead of being rewritten during optimization.

Reviewed by Cursor Bugbot for commit 5360ce6. Bugbot is set up for automated code reviews on this repo. Configure here.

Sharp already skips SVGs; without a matching filter, svgoMinify ran on raster assets and could fail or corrupt them during production builds.

Co-authored-by: Cursor <cursoragent@cursor.com>
prefixIds renames symbol IDs during production SVGO minimization, which
breaks icon sprites referenced as #icon-{slug} in PHP and markup.

Co-authored-by: Cursor <cursoragent@cursor.com>
@cedric07 cedric07 changed the title fix(build): restrict production SVGO minimizer to SVG files fix(build): SVGO minimizer SVG filter and stable sprite IDs Oct 19, 2026
Production SVGO on merged sprite SVGs collapses symbols; icons are already
optimized via svgo-loader at compile time. Matches BBT sprite workflow.

Co-authored-by: Cursor <cursoragent@cursor.com>
@cedric07 cedric07 changed the title fix(build): SVGO minimizer SVG filter and stable sprite IDs fix(build): production SVGO for SVG assets and stable icon sprites Oct 19, 2026

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit b518ada. Configure here.

Comment thread config/webpack.common.js Outdated
@cedric07
cedric07 marked this pull request as draft October 19, 2026 14:09
@cedric07
cedric07 marked this pull request as ready for review October 19, 2026 14:20
cedric07 and others added 3 commits October 19, 2026 16:21
Match webpack extract names like icons/sprite.svg so prod minify does not empty sprite sheets.

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
@cedric07
cedric07 merged commit ecb4312 into master Oct 20, 2026
6 checks passed
@cedric07
cedric07 deleted the fix/svgo-minimizer-svg-filter branch October 20, 2026 07:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants