- 根目录、zhican/、miniprogram/ 三层 .gitignore 就位 - 删除 package-lock.json,仓库统一追踪 pnpm-lock.yaml - vite.config.ts 拆出 vue-vendor(vue/vue-router/pinia); ant-design-vue 体积~1MB,继续按路由 code-split,不入 manualChunks - 新增根 CLAUDE.md 记录仓库结构、常用命令、antd 类型陷阱、 构建门禁、vendor 拆分策略等 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
51 lines
1.2 KiB
TypeScript
51 lines
1.2 KiB
TypeScript
import { defineConfig } from 'vite'
|
|
import vue from '@vitejs/plugin-vue'
|
|
import Components from 'unplugin-vue-components/vite'
|
|
import AutoImport from 'unplugin-auto-import/vite'
|
|
import { AntDesignVueResolver } from 'unplugin-vue-components/resolvers'
|
|
import { resolve } from 'path'
|
|
|
|
export default defineConfig({
|
|
plugins: [
|
|
vue(),
|
|
AutoImport({
|
|
imports: ['vue', 'vue-router', 'pinia'],
|
|
dts: 'src/auto-imports.d.ts',
|
|
}),
|
|
Components({
|
|
resolvers: [
|
|
AntDesignVueResolver({
|
|
importStyle: false,
|
|
}),
|
|
],
|
|
dts: 'src/components.d.ts',
|
|
}),
|
|
],
|
|
resolve: {
|
|
alias: {
|
|
'@': resolve(__dirname, 'src'),
|
|
},
|
|
},
|
|
server: {
|
|
port: 3000,
|
|
proxy: {
|
|
'/api': {
|
|
target: 'http://localhost:8080',
|
|
changeOrigin: true,
|
|
},
|
|
},
|
|
},
|
|
build: {
|
|
rollupOptions: {
|
|
output: {
|
|
// 拆分 vendor chunk
|
|
// 只提取所有路由都用到的"foundation"依赖,让 ant-design-vue 维持按路由代码分割
|
|
// —— antd 体积巨大(~1MB),强行打成单 chunk 反而拖累首屏;按路由 lazy 加载更优
|
|
manualChunks: {
|
|
'vue-vendor': ['vue', 'vue-router', 'pinia'],
|
|
},
|
|
},
|
|
},
|
|
},
|
|
})
|