Skip to content

Commit

Permalink
perf: 优化 vite-svg-loader 的 svgo 配置
Browse files Browse the repository at this point in the history
  • Loading branch information
pany-ang committed Dec 24, 2024
1 parent d34b7c9 commit 6ad8d08
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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")],
Expand Down

0 comments on commit 6ad8d08

Please sign in to comment.