|
| 1 | +/** |
| 2 | + * SVGO 3+ config for imagemin-svgo / svgo-loader. |
| 3 | + * |
| 4 | + * Format: SVGO 3 rejects the v2 style `{ cleanupAttrs: true }` (no `name` on plugin objects). |
| 5 | + * |
| 6 | + * Why not list every plugin like the old file? |
| 7 | + * - SVGO 3 expects either named plugins or `preset-default`, which bundles most optimizers |
| 8 | + * (cleanupAttrs, removeComments, convertPathData, mergePaths, etc.) in a maintained order. |
| 9 | + * Duplicating that full list in v3 `{ name, params }` form would be long and redundant. |
| 10 | + * - Reference: https://svgo.dev/docs/preset-default/ |
| 11 | + * |
| 12 | + * Mapping from the previous v2 `{ plugin: boolean }` list: |
| 13 | + * - `true` on a built-in → usually covered by `preset-default` (see link above). |
| 14 | + * - `false` falls into two cases in SVGO 3: |
| 15 | + * (A) Plugin is part of `preset-default` → turn it off with `params.overrides` |
| 16 | + * (e.g. `removeViewBox: false` below — removeViewBox runs inside the preset by default). |
| 17 | + * (B) Plugin is optional / not in the preset → do not list it; SVGO only runs plugins you |
| 18 | + * declare. So “false” in v2 = omit the plugin name here. |
| 19 | + * Examples from the old config: |
| 20 | + * - removeDimensions: https://svgo.dev/docs/plugins/removeDimensions/ — optional; not in |
| 21 | + * `preset-default`; we omit it so width/height stay (unless you add `'removeDimensions'`). |
| 22 | + * - removeRasterImages: https://svgo.dev/docs/plugins/removeRasterImages/ — optional; |
| 23 | + * not in `preset-default`; we omit it so embedded rasters are kept. |
| 24 | + * - Extra plugins the old list enabled but preset does not include: |
| 25 | + * `convertStyleToAttrs`, `prefixIds` — listed explicitly below (sprites / ID stability). |
| 26 | + */ |
1 | 27 | module.exports = { |
2 | 28 | plugins: [ |
3 | | - { cleanupAttrs: true }, |
4 | | - { removeDoctype: true }, |
5 | | - { removeXMLProcInst: true }, |
6 | | - { removeComments: true }, |
7 | | - { removeMetadata: true }, |
8 | | - { removeTitle: true }, |
9 | | - { removeDesc: true }, |
10 | | - { removeUselessDefs: true }, |
11 | | - { removeEditorsNSData: true }, |
12 | | - { removeEmptyAttrs: true }, |
13 | | - { removeHiddenElems: true }, |
14 | | - { removeEmptyText: true }, |
15 | | - { removeEmptyContainers: true }, |
16 | | - { cleanupEnableBackground: true }, |
17 | | - { convertStyleToAttrs: true }, |
18 | | - { convertColors: true }, |
19 | | - { convertPathData: true }, |
20 | | - { convertTransform: true }, |
21 | | - { removeUnknownsAndDefaults: true }, |
22 | | - { removeNonInheritableGroupAttrs: true }, |
23 | | - { removeUselessStrokeAndFill: true }, |
24 | | - { removeUnusedNS: true }, |
25 | | - { cleanupIDs: true }, |
26 | | - { cleanupNumericValues: true }, |
27 | | - { moveElemsAttrsToGroup: true }, |
28 | | - { moveGroupAttrsToElems: true }, |
29 | | - { collapseGroups: true }, |
30 | | - { removeRasterImages: false }, |
31 | | - { mergePaths: true }, |
32 | | - { convertShapeToPath: true }, |
33 | | - { sortAttrs: true }, |
34 | | - { removeDimensions: false }, |
35 | | - { prefixIds: true }, |
36 | | - { removeViewBox: false }, |
| 29 | + { |
| 30 | + name: 'preset-default', |
| 31 | + params: { |
| 32 | + overrides: { |
| 33 | + removeViewBox: false, |
| 34 | + }, |
| 35 | + }, |
| 36 | + }, |
| 37 | + 'convertStyleToAttrs', |
| 38 | + 'prefixIds', |
37 | 39 | ], |
38 | 40 | } |
0 commit comments