47 lines
1.2 KiB
JavaScript
47 lines
1.2 KiB
JavaScript
import { fileURLToPath, URL } from 'node:url'
|
|
import { defineConfig, loadEnv } from 'vite'
|
|
import uniPlugin from '@dcloudio/vite-plugin-uni'
|
|
|
|
const uni = typeof uniPlugin === 'function' ? uniPlugin : uniPlugin.default
|
|
|
|
export default defineConfig(({ mode }) => {
|
|
const env = loadEnv(mode, process.cwd(), '')
|
|
const iceApiBase = env.VITE_ICE_API_BASE_URL || 'http://127.0.0.1:8000'
|
|
const comprehensiveApiBase = env.VITE_COMPREHENSIVE_API_BASE_URL || 'http://127.0.0.1:8001'
|
|
|
|
return {
|
|
plugins: [uni()],
|
|
optimizeDeps: {
|
|
include: ['uview-plus'],
|
|
},
|
|
resolve: {
|
|
alias: {
|
|
'@': fileURLToPath(new URL('./src', import.meta.url)),
|
|
},
|
|
},
|
|
css: {
|
|
preprocessorOptions: {
|
|
scss: {
|
|
api: 'modern-compiler',
|
|
},
|
|
},
|
|
},
|
|
server: {
|
|
proxy: {
|
|
'/ice-api': {
|
|
target: iceApiBase,
|
|
changeOrigin: true,
|
|
secure: false,
|
|
rewrite: (path) => path.replace(/^\/ice-api/, ''),
|
|
},
|
|
'/comprehensive-api': {
|
|
target: comprehensiveApiBase,
|
|
changeOrigin: true,
|
|
secure: false,
|
|
rewrite: (path) => path.replace(/^\/comprehensive-api/, ''),
|
|
},
|
|
},
|
|
},
|
|
}
|
|
})
|