generated from common/vue-front
61 lines
1.6 KiB
JavaScript
61 lines
1.6 KiB
JavaScript
import { defineConfig, loadEnv } from 'vite'
|
|
import createVitePlugins from './vite/plugins'
|
|
import { resolve } 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: {
|
|
// 设置路径
|
|
'~': resolve(__dirname, './'),
|
|
// 设置别名
|
|
'@': resolve(__dirname, 'src')
|
|
},
|
|
extensions: ['.mjs', '.js', '.ts', '.jsx', '.tsx', '.json', '.vue']
|
|
},
|
|
server: {
|
|
port: 3500,
|
|
host: true,
|
|
proxy: {
|
|
'/api': {
|
|
// target: 'http://117.62.238.129:10050',
|
|
target: 'http://117.62.238.129:10050',
|
|
// target: 'http://10.70.132.177:11002',
|
|
ws: false,
|
|
changeOrigin: true
|
|
},
|
|
'/poll': {
|
|
// target: 'http://117.62.238.129:6066',
|
|
target: 'http://117.62.238.129:6066',
|
|
// target: 'http://10.70.132.177:11002',
|
|
pathRewrite: { '^/poll': '' },
|
|
ws: false,
|
|
changeOrigin: true,
|
|
rewrite: (path) => path.replace(/^\/poll/, '')
|
|
}
|
|
}
|
|
},
|
|
css: {
|
|
postcss: {
|
|
plugins: [
|
|
{
|
|
postcssPlugin: 'internal:charset-removal',
|
|
AtRule: {
|
|
charset: (atRule) => {
|
|
if (atRule.name === 'charset') {
|
|
atRule.remove();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
]
|
|
}
|
|
}
|
|
}
|
|
})
|