Commit 486401d1 authored by tyyin lan's avatar tyyin lan

build: 应用拆包

parent 55504f08
......@@ -25,3 +25,5 @@ dist-ssr
auto-imports.d.ts
components.d.ts
package-lock.json
chunk-stats.html
......@@ -10,8 +10,6 @@ import UnoCSS from 'unocss/vite'
import VueJsx from '@vitejs/plugin-vue-jsx'
export function setupPlugins(isBuild: boolean, envConf: ViteEnv, pathResolve: (dir: string) => string): PluginOption[] {
const lifecycle = process.env.npm_lifecycle_event
const plugins: PluginOption = [
vue(),
AutoImport({
......@@ -35,8 +33,12 @@ export function setupPlugins(isBuild: boolean, envConf: ViteEnv, pathResolve: (d
plugins.push(checker({ vueTsc: true }))
}
if (lifecycle === 'report') {
plugins.push(visualizer())
if (envConf.VITE_VITEST) {
plugins.push(
visualizer({
filename: 'chunk-stats.html',
}),
)
}
return plugins
......
......@@ -36,5 +36,18 @@ export default defineConfig(({ command, mode }) => {
},
},
},
build: {
rollupOptions: {
output: {
manualChunks: {
dompurify: ['dompurify'],
'highlight.js': ['highlight.js'],
marked: ['marked'],
'github-markdown-css': ['github-markdown-css'],
'marked-highlight': ['marked-highlight'],
},
},
},
},
}
})
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment