Files
urbanLifeline/urbanLifelineWeb/packages/platform/vite.config.ts

80 lines
1.6 KiB
TypeScript
Raw Normal View History

2025-12-06 14:49:46 +08:00
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import vueJsx from '@vitejs/plugin-vue-jsx'
2025-12-11 14:21:36 +08:00
import { federation } from '@module-federation/vite'
2025-12-06 14:49:46 +08:00
import { resolve, dirname } from 'path'
import { fileURLToPath } from 'url'
const __filename = fileURLToPath(import.meta.url)
const __dirname = dirname(__filename)
2025-12-13 14:13:31 +08:00
2025-12-06 14:49:46 +08:00
export default defineConfig({
2025-12-13 14:13:31 +08:00
// Platform 是根路径应用
base: '/',
2025-12-11 14:21:36 +08:00
plugins: [
vue({
script: {
defineModel: true,
propsDestructure: true
}
}),
vueJsx(),
federation({
name: 'platform',
remotes: {
shared: {
type: 'module',
name: 'shared',
entry: 'http://localhost:5000/remoteEntry.js'
}
},
shared: {
vue: {},
'vue-router': {},
'element-plus': {},
axios: {}
}
})
],
define: {
__VUE_OPTIONS_API__: true,
__VUE_PROD_DEVTOOLS__: true,
__VUE_PROD_HYDRATION_MISMATCH_DETAILS__: true
},
2025-12-06 14:49:46 +08:00
resolve: {
alias: {
'@': resolve(__dirname, 'src')
}
},
server: {
port: 5001,
host: true,
cors: true,
2025-12-13 14:13:31 +08:00
open: '/', // 开发时自动打开到根路径
2025-12-06 14:49:46 +08:00
proxy: {
'/api': {
2025-12-11 16:26:48 +08:00
target: 'http://localhost:8180',
2025-12-06 14:49:46 +08:00
changeOrigin: true,
rewrite: (path: string) => path.replace(/^\/api/, '')
}
}
},
build: {
outDir: 'dist',
sourcemap: true,
rollupOptions: {
output: {
manualChunks: {
'vue-vendor': ['vue', 'vue-router', 'pinia'],
'element-plus': ['element-plus']
}
}
}
}
})