Procházet zdrojové kódy

fix: 消除自定义插件警告

BaiLuoYan před 4 týdny
rodič
revize
c5eacbc8e0
1 změnil soubory, kde provedl 3 přidání a 1 odebrání
  1. 3 1
      build/svgConvert.ts

+ 3 - 1
build/svgConvert.ts

@@ -39,6 +39,7 @@ export default function svgConvert(options: Options = {}): Plugin {
                     const innerContent = svgContent.replace(/<svg[^>]*>([\s\S]*)<\/svg>/i, '$1');
                     return {
                         code: `export default {width: ${width}, height: ${height}, body: ${JSON.stringify(innerContent)}}`,
+                        map: null,
                     };
                 }
             }
@@ -91,9 +92,10 @@ export default function svgConvert(options: Options = {}): Plugin {
             // 提取 SVG 标签内的内容
             const innerContent = optimizedSvg.replace(/<svg[^>]*>([\s\S]*)<\/svg>/i, '$1');
 
-            // 返回转换后的代码
+            // 返回转换后的代码(不生成 sourcemap,避免 Vite 警告)
             return {
                 code: `export default {width: ${width}, height: ${height}, body: ${JSON.stringify(innerContent)}}`,
+                map: null,
             };
         },
     };