Configure multi-pages applications and code splitting
npm install vite-plugin-mp -D
// vite.config.js
import { defineConfig } from 'vite'
import { ViteMpPlugin } from 'vite-plugin-mp'
export default defineConfig({
plugins: [ViteMpPlugin()],
})
add jsconfig.json
or tsconfig.json
to your project
{
"compilerOptions": {
"baseUrl": ".",
"paths": {
"@/*": ["./src/*"],
"src/*": ["./src/*"]
}
},
"include": ["src"]
}
if you want to force extract node_modules
for vendor
, you can import splitVendorChunkPlugin
// vite.config.js
import { defineConfig, splitVendorChunkPlugin } from 'vite'
import { ViteMpPlugin } from 'vite-plugin-mp'
export default defineConfig({
plugins: [ViteMpPlugin(), splitVendorChunkPlugin()],
})
See example and https://zhuweiyou.github.io/vite-plugin-mp/
- vite-plugin-minify - Minify html in production