-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.config.ts
More file actions
executable file
·61 lines (58 loc) · 1.66 KB
/
Copy pathvite.config.ts
File metadata and controls
executable file
·61 lines (58 loc) · 1.66 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import path from 'path'
import { defineConfig, loadEnv } from 'vite'
import presets from './build/presets'
// https://vitejs.dev/config/
export default defineConfig(({ command, mode }) => {
const isBuild = command === 'build'
const env = loadEnv(mode, process.cwd(), '')
return {
base: env.VITE_BASE,
plugins: [presets(env, isBuild)],
resolve: {
// 设置别名
alias: {
'@': path.resolve(__dirname, 'src')
}
},
assetsInclude: ['**/*.gltf'],
server: {
host: '0.0.0.0', // 主机名
port: env.VITE_PORT, // 端口
open: false, // 自动打开浏览器
cors: true, // 跨域设置允许
strictPort: false, // 如果端口已占用直接退出
// 接口代理
proxy: {
'/api': {
// 本地 8000 前端代码的接口 代理到 8888 的服务端口
target: 'http://localhost:8888/',
changeOrigin: true, // 允许跨域
rewrite: (path) => path.replace('/api/', '/')
}
}
},
build: {
sourcemap: true,
brotliSize: false,
// 消除打包大小超过500kb警告
chunkSizeWarningLimit: 2000,
// 在生产环境移除console.log
minify: 'terser',
terserOptions: {
compress: {
drop_console: true,
drop_debugger: true
}
},
assetsDir: 'static/assets',
// 静态资源打包到dist下的不同目录
rollupOptions: {
output: {
chunkFileNames: 'static/js/[name]-[hash].js',
entryFileNames: 'static/js/[name]-[hash].js',
assetFileNames: 'static/[ext]/[name]-[hash].[ext]'
}
}
}
}
})