When vue3+ts+vite is packaged, it prompts 【vite (!) Some chunks are larger than 500 kBs after minification.】

When vue3+ts+vite is packaged, it prompts 【vite (!) Some chunks are larger than 500 kBs after minification.】

Reference link: [Vue3] Vite packaging error: the size of the block exceeds the limit, Some chunks are larger than 500kb after minification

The settings in the vite.config.ts file are as follows:

// 扩大块限制
  build: {
    
    
      sourcemap: false,
      minify: 'terser',
      chunkSizeWarningLimit: 1500,
      terserOptions: {
    
    
        compress: {
    
    
          drop_console: true,
          drop_debugger: true
        }
      },
      rollupOptions: {
    
    
        output: {
    
    
          manualChunks(id) {
    
    
            if (id.includes('node_modules')) {
    
    
              return id
                .toString()
                .split('node_modules/')[1]
                .split('/')[0]
                .toString();
            }
          },
          chunkFileNames: (chunkInfo) => {
    
    
            const facadeModuleId = chunkInfo.facadeModuleId
              ? chunkInfo.facadeModuleId.split('/')
              : [];
            const fileName =
              facadeModuleId[facadeModuleId.length - 2] || '[name]';
            return `js/${
      
      fileName}/[name].[hash].js`;
          }
        }
      }
  }

おすすめ

転載: blog.csdn.net/heavenz19/article/details/131390370
おすすめ