vite-plugin-mp
v3.0.0
Published
Configure multi-pages applications and code splitting
Maintainers
Readme
vite-plugin-mp
Configure multi-pages applications and code splitting for Vite.
Usage
npm install vite-plugin-mp -D// vite.config.js
import { defineConfig } from 'vite'
import { ViteMpPlugin } from 'vite-plugin-mp'
export default defineConfig({
plugins: [ViteMpPlugin()],
})How it works
The plugin automatically:
- Sets
roottosrc/ - Discovers all
*.htmlfiles undersrc/as Rollup entry points - Configures
@andsrcpath aliases pointing tosrc/ - Sets
publicDirto<project>/public - Sets
outDirto<project>/distwithemptyOutDir: true
Add jsconfig.json or tsconfig.json to enable path alias intellisense:
{
"compilerOptions": {
"baseUrl": ".",
"paths": {
"@/*": ["./src/*"],
"src/*": ["./src/*"]
}
},
"include": ["src"]
}Directory structure
├── public/
├── src/
│ ├── index.html
│ ├── react/
│ │ ├── index.html
│ │ ├── main.jsx
│ │ ├── App.jsx
│ │ └── ...
│ └── vue/
│ ├── index.html
│ ├── main.js
│ ├── App.vue
│ └── ...
├── jsconfig.json
├── vite.config.js
└── package.jsonOutput
After vite build:
dist/
├── index.html
├── react/
│ └── index.html
├── vue/
│ └── index.html
└── assets/
├── react-xxx.js
├── react-xxx.css
├── vue-xxx.js
└── vue-xxx.cssExample
See example and https://zhuweiyou.github.io/vite-plugin-mp/.
