51 lines
1.3 KiB
TypeScript
51 lines
1.3 KiB
TypeScript
|
|
import { fileURLToPath, URL } from 'node:url'
|
||
|
|
|
||
|
|
import { defineConfig,loadEnv } from 'vite'
|
||
|
|
import type { PluginOption } from 'vite'
|
||
|
|
import vue from '@vitejs/plugin-vue'
|
||
|
|
import vueDevTools from 'vite-plugin-vue-devtools'
|
||
|
|
import AutoImport from 'unplugin-auto-import/vite'
|
||
|
|
import Components from 'unplugin-vue-components/vite'
|
||
|
|
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
|
||
|
|
|
||
|
|
function setupPlugins(env: ImportMetaEnv): PluginOption[] {
|
||
|
|
return [
|
||
|
|
vue(),
|
||
|
|
vueDevTools(),
|
||
|
|
// topLevelAwait(),
|
||
|
|
AutoImport({
|
||
|
|
resolvers: [ElementPlusResolver()],
|
||
|
|
}),
|
||
|
|
Components({
|
||
|
|
resolvers: [ElementPlusResolver()],
|
||
|
|
}),
|
||
|
|
]
|
||
|
|
}
|
||
|
|
|
||
|
|
export default defineConfig((env) => {
|
||
|
|
const viteEnv = loadEnv(env.mode, process.cwd()) as unknown as ImportMetaEnv
|
||
|
|
return {
|
||
|
|
base: viteEnv.VITE_GLOB_FRONT_CTX,
|
||
|
|
plugins: setupPlugins(viteEnv),
|
||
|
|
server: {
|
||
|
|
host: '0.0.0.0',
|
||
|
|
port: viteEnv.VITE_GLOB_FRONT_PORT,
|
||
|
|
open: false,
|
||
|
|
proxy: {
|
||
|
|
[viteEnv.VITE_GLOB_API_CTX]: {
|
||
|
|
target: viteEnv.VITE_GLOB_API_DEV_IP,
|
||
|
|
changeOrigin: true,
|
||
|
|
}
|
||
|
|
},
|
||
|
|
},
|
||
|
|
build: {
|
||
|
|
target: 'esnext',
|
||
|
|
},
|
||
|
|
resolve: {
|
||
|
|
alias: {
|
||
|
|
'@': fileURLToPath(new URL('./src', import.meta.url))
|
||
|
|
},
|
||
|
|
},
|
||
|
|
}
|
||
|
|
})
|