Browse Source

打包切片一下

Karsa 2 years ago
parent
commit
9e9def8fec
1 changed files with 19 additions and 0 deletions
  1. 19 0
      vite.config.ts

+ 19 - 0
vite.config.ts

@@ -27,6 +27,25 @@ export default defineConfig({
 	},
   build: {
     outDir: 'horz_chart',
+		chunkSizeWarningLimit: 800,//单文件过800kb警告
+		rollupOptions: {
+			output: {
+				manualChunks(id) {
+					if (id.includes('node_modules')) {
+						return id.toString()
+							.split('node_modules/')[1]
+							.split('/')[0]
+							.toString();
+					}
+				},
+				chunkFileNames: (info) => {
+					const facadeModuleId = info.facadeModuleId ?
+					info.facadeModuleId.split('/') : [];
+					const fileName = facadeModuleId[facadeModuleId.length -2] || '[name]'
+					return `js/${fileName}/[name].[hash].js`;
+				}
+			}
+		}
   },
   resolve: {
 		alias: {