Vite packing error: some chunks are larger than 500kb after minification
Solution 1: increase the size of the limit and change 500kb to 1000KB or more
chunkSizeWarningLimit:1500,
build.chunkSizeWarningLimit
Type:
number
Default:500
limit of block size warning (in KBS).
Solution 2: decompose blocks, breaking large blocks into smaller blocks
rollupOptions: {
output:{
manualChunks(id) {
if (id.includes('node_modules')) {
return id.toString().split('node_modules/')[1].split('/')[0].toString();
}
}
}
}
build.rollupOptions
Type:
rollupoptions
directly customize the underlying rollup package. This is the same as the options that can be exported from the rollup configuration file and will be combined with vite’s internal rollup options. For more details, see the summary options documentation.
code:
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import styleImport from 'vite-plugin-style-import'
import { resolve } from 'path'
// https://vitejs.dev/config/
export default defineConfig({
base: '/dist/',
build: {
chunkSizeWarningLimit:1500,
rollupOptions: {
output:{
manualChunks(id) {
if (id.includes('node_modules')) {
return id.toString().split('node_modules/')[1].split('/')[0].toString();
}
}
}
}
}
})