From 6ad8d08ff4f721c163acbb2d2b7cd0d7fe316f71 Mon Sep 17 00:00:00 2001 From: pany <939630029@qq.com> Date: Tue, 24 Dec 2024 20:25:14 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E4=BC=98=E5=8C=96=20vite-svg-loader=20?= =?UTF-8?q?=E7=9A=84=20svgo=20=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- vite.config.ts | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/vite.config.ts b/vite.config.ts index 0b5d4bd0..454218f3 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -96,7 +96,22 @@ export default defineConfig(({ mode }) => { // 支持 JSX、TSX 语法 vueJsx(), // 支持将 SVG 文件导入为 Vue 组件 - svgLoader({ defaultImport: "url" }), + svgLoader({ + defaultImport: "url", + svgoConfig: { + plugins: [ + { + name: "preset-default", + params: { + overrides: { + // @see https://github.com/svg/svgo/issues/1128 + removeViewBox: false + } + } + } + ] + } + }), // 自动生成 SvgIcon 组件和 SVG 雪碧图 SvgComponent({ iconDir: [resolve(__dirname, "src/common/assets/icons")],