From bc4c577149049360957293e21bba7a737e579662 Mon Sep 17 00:00:00 2001 From: winixt Date: Thu, 27 Oct 2022 19:46:24 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=20icon-plugin=20viewB?= =?UTF-8?q?ox=20=E5=88=A0=E9=99=A4=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/fes-plugin-icon/src/optimizeSvg.js | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/packages/fes-plugin-icon/src/optimizeSvg.js b/packages/fes-plugin-icon/src/optimizeSvg.js index 545a6885..8673f230 100644 --- a/packages/fes-plugin-icon/src/optimizeSvg.js +++ b/packages/fes-plugin-icon/src/optimizeSvg.js @@ -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, }); } }