Skip to content

Commit 5360ce6

Browse files
cedric07cursoragent
andcommitted
refactor(build): exclude icons/ at ImageMinimizerPlugin level
Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 80593de commit 5360ce6

1 file changed

Lines changed: 3 additions & 17 deletions

File tree

‎config/webpack.common.js‎

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ module.exports = {
1515
optimization: {
1616
minimizer: [
1717
new ImageMinimizerPlugin({
18+
// svg-sprite-loader extract publicPath; sprites are already optimized via svgo-loader.
19+
exclude: /(?:^|[/\\])icons[/\\]/i,
1820
minimizer: [
1921
{
2022
implementation: ImageMinimizerPlugin.sharpMinify,
@@ -44,23 +46,7 @@ module.exports = {
4446
},
4547
{
4648
implementation: ImageMinimizerPlugin.svgoMinify,
47-
// Return true to run SVGO on this asset, false to leave it unchanged.
48-
// sourcePath is the webpack compilation asset name (e.g. icons/sprite.svg).
49-
filter: (source, sourcePath) => {
50-
// Only SVG assets go through SVGO (raster images use sharpMinify above).
51-
if (!/\.svg$/i.test(sourcePath)) {
52-
return false
53-
}
54-
55-
// Skip extracted sprite sheets under icons/ (svg-sprite-loader publicPath).
56-
// Those files only hold <symbol> defs; SVGO treats them as unused and
57-
// strips them, which empties the sprite and breaks #icon-* references.
58-
if (/(?:^|[/\\])icons[/\\]/i.test(sourcePath)) {
59-
return false
60-
}
61-
62-
return true
63-
},
49+
filter: (source, sourcePath) => /\.svg$/i.test(sourcePath),
6450
options: {
6551
encodeOptions: {
6652
multipass: true,

0 commit comments

Comments
 (0)