gameapi-client/vite.config.js

74 lines
2.3 KiB
JavaScript
Raw Permalink Normal View History

2025-08-14 10:33:48 +08:00
import { defineConfig, loadEnv } from 'vite'
import path from 'path'
import createVitePlugins from './vite/plugins'
export default defineConfig(({ mode, command }) => {
const env = loadEnv(mode, process.cwd())
const { VITE_APP_ENV } = env
const buildTime = new Date().getTime()
return {
base: VITE_APP_ENV === 'production' ? '/' : '/',
plugins: [
...createVitePlugins(env, command === 'build'),
],
resolve: {
alias: {
// 设置路径
'~': path.resolve(__dirname, './'),
// 设置别名
'@': path.resolve(__dirname, './src')
},
extensions: ['.mjs', '.js', '.ts', '.jsx', '.tsx', '.json', '.vue']
},
// vite 相关配置
server: {
port: 80,
host: true,
open: true,
proxy: {
2025-10-10 10:10:53 +08:00
'/dev-api': {
target: 'http://192.168.50.234:9080',
// target: 'http://192.168.50.11:9080',
// target: 'http://192.168.50.178:8080',
// target: 'http://192.168.50.99:8080',
changeOrigin: true,
rewrite: (p) => p.replace(/^\/dev-api/, '')
2025-08-14 10:33:48 +08:00
}
2025-10-10 10:10:53 +08:00
},
// proxy: {
// '/ff-api': {
// target: 'https://apiadmin.tt-gaming.com', // 线上接口地址
// changeOrigin: true, // 是否允许跨域
// pathRewrite: {
// '^/ff-api': '' // 如果你需要去掉前缀,例如将 /api/xxx 替换为 /xxx
// }
// }
// }
2025-08-14 10:33:48 +08:00
},
css: {
postcss: {
plugins: [
{
postcssPlugin: 'internal:charset-removal',
AtRule: {
charset: (atRule) => {
if (atRule.name === 'charset') {
atRule.remove();
}
}
}
}
]
}
},
build: {
rollupOptions: {
output: {
entryFileNames: 'assets/[name].[hash].js',
chunkFileNames: 'assets/[name].[hash].js',
assetFileNames: 'assets/[name].[hash].[ext]'
}
}
}
}
})