orgManager/vite.config.js

74 lines
2.3 KiB
JavaScript
Raw Normal View History

2025-08-14 10:38:42 +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,
2025-09-04 09:20:44 +08:00
// proxy: {
2025-09-24 20:41:00 +08:00
// '/dev-api': {
// // target: 'http://192.168.50.139:9080',
// target: 'http://192.168.50.234:8081',
2025-10-10 10:10:02 +08:00
// // target: 'http://192.168.50.178:8081',
2025-09-24 20:41:00 +08:00
// // target: 'http://192.168.50.11:8081',
// changeOrigin: true,
// rewrite: (p) => p.replace(/^\/dev-api/, '')
2025-09-04 09:20:44 +08:00
// }
2025-09-24 20:41:00 +08:00
// },
proxy: {
'/ff-api': {
target: 'https://osssuper.kk9game.com', // 线上接口地址
changeOrigin: true, // 是否允许跨域
pathRewrite: {
'^/ff-api': '' // 如果你需要去掉前缀,例如将 /api/xxx 替换为 /xxx
}
}
}
2025-08-14 10:38:42 +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]'
}
}
}
}
})