Skip to content

Commit

Permalink
chore: 引入bundle分析 拆包
Browse files Browse the repository at this point in the history
  • Loading branch information
ZiuChen committed Jan 22, 2024
1 parent bdf0e64 commit 8cc5006
Show file tree
Hide file tree
Showing 4 changed files with 157 additions and 5 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@
/node_modules
**/.DS_Store

components.d.ts
components.d.ts

stats.html
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"scripts": {
"dev": "vite",
"build": "vue-tsc && vite build",
"build:preview": "vue-tsc && vite build --mode=preview",
"preview": "vite preview"
},
"dependencies": {
Expand All @@ -24,6 +25,7 @@
"@vitejs/plugin-vue": "^5.0.2",
"html-minifier-terser": "^7.2.0",
"less": "^4.2.0",
"rollup-plugin-visualizer": "^5.12.0",
"typescript": "^4.9.5",
"unplugin-auto-import": "^0.14.4",
"unplugin-vue-components": "^0.24.1",
Expand Down
147 changes: 146 additions & 1 deletion pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 6 additions & 3 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import { ArcoResolver } from 'unplugin-vue-components/resolvers'
import { createStyleImportPlugin } from 'vite-plugin-style-import'
import { visualizer } from 'rollup-plugin-visualizer'
import postBuildPlugin from './build/postBuildPlugin'

export default defineConfig({
export default defineConfig(({ mode }) => ({
base: './',
resolve: {
alias: {
Expand All @@ -31,6 +32,7 @@ export default defineConfig({
output: {
manualChunks: (e) => {
if (e.includes('/node_modules/monaco-editor/')) return 'monaco'
if (e.includes('@babel/standalone')) return 'babel'
return 'vendor'
}
},
Expand Down Expand Up @@ -77,6 +79,7 @@ export default defineConfig({
}),
postBuildPlugin({
files: ['index.html', 'plugin.json', 'preload.js']
})
}),
mode === 'preview' && visualizer()
]
})
}))

0 comments on commit 8cc5006

Please sign in to comment.