53 lines
1.3 KiB
JavaScript
53 lines
1.3 KiB
JavaScript
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: {
|
|
port: 7777,
|
|
host: true,
|
|
open: true,
|
|
proxy: {
|
|
// https://cn.vitejs.dev/config/#server-proxy
|
|
'/dev-api': {
|
|
target: 'http://localhost:6789',
|
|
// target: 'http://117.62.238.129:6789',
|
|
changeOrigin: true,
|
|
rewrite: (p) => p.replace(/^\/dev-api/, '')
|
|
}
|
|
}
|
|
},
|
|
css: {
|
|
postcss: {
|
|
plugins: [
|
|
{
|
|
postcssPlugin: 'internal:charset-removal',
|
|
AtRule: {
|
|
charset: (atRule) => {
|
|
if (atRule.name === 'charset') {
|
|
atRule.remove();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
]
|
|
}
|
|
}
|
|
}
|
|
})
|