Browse Source

更新 'vite.config.ts'

Caner 3 years ago
parent
commit
bf78506b1f
1 changed files with 11 additions and 1 deletions
  1. 11 1
      vite.config.ts

+ 11 - 1
vite.config.ts

@@ -41,7 +41,17 @@ export default defineConfig({
       output: { // 静态资源分类打包
       output: { // 静态资源分类打包
         chunkFileNames: 'js/[name]-[hash].js',
         chunkFileNames: 'js/[name]-[hash].js',
         entryFileNames: 'js/[name]-[hash].js',
         entryFileNames: 'js/[name]-[hash].js',
-        assetFileNames: 'assets/[name]-[hash].[ext]'
+        assetFileNames: 'assets/[name]-[hash].[ext]',
+        // 拆分node_modules包
+        manualChunks: (id: any) => {
+          if (id.includes("node_modules")) {
+            return id
+              .toString()
+              .split("node_modules/")[1]
+              .split("/")[0]
+              .toString();
+          }
+        }          
       }
       }
     },
     },
     terserOptions: { // 去掉打印
     terserOptions: { // 去掉打印