fix: 修复 icon-plugin viewBox 删除问题

This commit is contained in:
winixt 2022-10-27 19:46:24 +08:00
parent b227817159
commit bc4c577149

View File

@ -4,18 +4,22 @@ import { optimize } from 'svgo';
const presetDefault = [
{
name: 'preset-default'
name: 'preset-default',
params: {
overrides: {
removeViewBox: false,
},
},
},
'cleanupListOfValues',
{
name: 'removeAttrs',
params: {
attrs: '(fill|stroke|class)'
}
}
attrs: '(fill|stroke|class)',
},
},
];
export default function optimizeSvg(files) {
const optimizedSvgData = [];
for (const filePath of files) {
@ -24,7 +28,7 @@ export default function optimizeSvg(files) {
const svgData = optimize(data, { path: filePath, plugins: presetDefault });
optimizedSvgData.push({
fileName: basename(filePath),
...svgData
...svgData,
});
}
}