chat-custom/vite.config.js

61 lines
1.6 KiB
JavaScript
Raw Normal View History

2024-05-15 10:10:35 +08:00
import { defineConfig, loadEnv } from 'vite'
import createVitePlugins from './vite/plugins'
import path from 'path'
// https://vitejs.dev/config/
export default defineConfig(({ mode, command }) => {
const env = loadEnv(mode, process.cwd())
const { VITE_APP_ENV } = env
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']
},
server: {
2024-05-15 11:15:11 +08:00
port: 3500,
2024-05-15 10:10:35 +08:00
host: true,
open: true,
proxy: {
2024-05-15 11:15:11 +08:00
'/api': {
// target: 'http://117.62.238.129:10050',
target: 'http://192.168.50.101:10050',
// target: 'http://10.70.132.177:11002',
ws: false,
changeOrigin: true
},
'/poll': {
// target: 'http://117.62.238.129:6066',
target: 'http://192.168.50.101:6066',
// target: 'http://10.70.132.177:11002',
pathRewrite: { '^/poll': '' },
ws: false,
changeOrigin: true
2024-05-15 10:10:35 +08:00
}
}
},
css: {
postcss: {
plugins: [
{
postcssPlugin: 'internal:charset-removal',
AtRule: {
charset: (atRule) => {
if (atRule.name === 'charset') {
atRule.remove();
}
}
}
}
]
}
}
}
})