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();
}
}
}
}
}
})
Read More:
- [Solved] Some chunks are bigger warning on vite packaging
- [Solved] vite package Error: globalThis is not defined
- [Solved] arco design vite-plugin-style-import Load menu-item error: Internal server error…
- After Vite starts, it will prompt “network: use ` — host ` to expose”, and the service cannot be accessed through network IP
- Vue3 + vite install element-plus error [How to Solve]
- [Solved] Temporary error: Error: spawn E:\vue3-vite\my-app\node_modules\esbuild\esbuild.exe ENOENT
- [Solved] vite2+vue3 jsx Error: React is not defined
- How to Solve Vite package error
- Method of identifying vite alias path by idea webstorm
- [Solved] vue3vite Error: Failed to resolve import “@vue/server-renderer from “src\App.vue“. Does the file exist
- [Solved] Vite Error: Failed to load module script: Expected a JavaScript module script but the server…
- [Solved] Error:Plugin/Preset files are not allowed to export objects, only functions
- JavaScript determines whether parentheses are paired.
- [Solved] react-router-dom Error: index.js:1 Warning: Functions are not valid as a React child.
- [Weex]Error in creating project NPM: unable to load file D:\program files\nodejs\node_ global\ weex.ps1 Because scripts are not allowed to run on this system.
- [Solved] error when starting dev server:Error: The following dependencies are imported but could not be reso
- [Solved] Vue3 Error: Cant find variable: GlobalThis
- [vite] Failed to parse source for import analysis because the content contains invalid JS syntax.
- [Solved] NPM Error: FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed
- [Solved] Error: Transform failed with 1 error: error: Invalid option in transform() call: “jsx“