-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.config.js
More file actions
47 lines (43 loc) · 1.09 KB
/
vite.config.js
File metadata and controls
47 lines (43 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import { fileURLToPath, URL } from 'node:url'
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
export default defineConfig({
// 插件配置
plugins: [
vue()
],
// 路径解析
resolve: {
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url))
}
},
// 开发服务器
server: {
port: 5174,
open: true, // 自动打开浏览器
proxy: {
'/api': {
target: 'http://localhost:3000', // 后端服务器地址
changeOrigin: true,
rewrite: (path) => path.replace(/^\/api/, '')
}
}
},
// 构建配置
build: {
outDir: 'dist',
sourcemap: false, // 生产环境不生成 sourcemap
chunkSizeWarningLimit: 10000, // 10MB 警告限制
rollupOptions: {
output: {
// 打包成单个文件
manualChunks: undefined, // 禁用代码分割
inlineDynamicImports: true, // 内联动态导入
entryFileNames: 'assets/index.js', // 固定主文件名
chunkFileNames: 'assets/[name].js',
assetFileNames: 'assets/[name].[ext]'
}
}
}
})