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