Skip to content

Commit 6ad8d08

Browse files
committed
perf: 优化 vite-svg-loader 的 svgo 配置
1 parent d34b7c9 commit 6ad8d08

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

vite.config.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,22 @@ export default defineConfig(({ mode }) => {
9696
// 支持 JSX、TSX 语法
9797
vueJsx(),
9898
// 支持将 SVG 文件导入为 Vue 组件
99-
svgLoader({ defaultImport: "url" }),
99+
svgLoader({
100+
defaultImport: "url",
101+
svgoConfig: {
102+
plugins: [
103+
{
104+
name: "preset-default",
105+
params: {
106+
overrides: {
107+
// @see https://github.com/svg/svgo/issues/1128
108+
removeViewBox: false
109+
}
110+
}
111+
}
112+
]
113+
}
114+
}),
100115
// 自动生成 SvgIcon 组件和 SVG 雪碧图
101116
SvgComponent({
102117
iconDir: [resolve(__dirname, "src/common/assets/icons")],

0 commit comments

Comments
 (0)