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'
2024-05-17 13:21:50 +08:00
import { resolve } from 'path'
2024-05-15 10:10:35 +08:00
// 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: {
// 设置路径
2024-05-17 13:21:50 +08:00
'~': resolve(__dirname, './'),
2024-05-15 10:10:35 +08:00
// 设置别名
2024-05-17 13:21:50 +08:00
'@': resolve(__dirname, 'src')
2024-05-15 10:10:35 +08:00
},
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,
proxy: {
2024-05-15 11:15:11 +08:00
'/api': {
2024-05-20 15:16:58 +08:00
// target: 'http://117.62.238.129:10050',
target: 'http://117.62.238.129:10050',
2024-05-15 11:15:11 +08:00
// target: 'http://10.70.132.177:11002',
ws: false,
changeOrigin: true
},
'/poll': {
2024-05-20 15:16:58 +08:00
// target: 'http://117.62.238.129:6066',
target: 'http://117.62.238.129:6066',
2024-05-15 11:15:11 +08:00
// target: 'http://10.70.132.177:11002',
pathRewrite: { '^/poll': '' },
ws: false,
2024-05-17 13:21:50 +08:00
changeOrigin: true,
rewrite: (path) => path.replace(/^\/poll/, '')
2024-05-15 10:10:35 +08:00
}
}
},
css: {
postcss: {
plugins: [
{
postcssPlugin: 'internal:charset-removal',
AtRule: {
charset: (atRule) => {
if (atRule.name === 'charset') {
atRule.remove();
}
}
}
}
]
}
}
}
})