Skip to content
Discussion options

You must be logged in to vote

vite-plugin-svg-icons 每一个 transform 都会 load 一次,调用一次fs.glob查找所有svg,该io操作在windows中很慢。可以在 node_module/vite-plugin-svg-icons/dist/index.mjs 中做如下修改,来测试是否有改进。

let svgFilsStats = null <--- add this line  

async function compilerIcons(cache, svgOptions, options) {
  const { iconDirs } = options;
  let insertHtml = "";
  const idSet = /* @__PURE__ */ new Set();
  for (const dir of iconDirs) {
    svgFilsStats ??= fg.sync("**/*.svg", { <--- change this line  
      cwd: dir,
      stats: true,
      absolute: true
    });

建议换一个svg图标库。


Every time a transform occurs in vite-plugin-svg-icons, it loads once and calls fs.glob to search for all svgs. This IO operation is very slow in Windows. The follo…

Replies: 5 comments 4 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@zhoufanglu
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
3 replies
@zhoufanglu
Comment options

@vovsemenv
Comment options

@JaydenI2I38
Comment options

Answer selected by sapphi-red
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
8 participants
Converted from issue

This discussion was converted from issue #15739 on January 29, 2024 08:29.