import { fileURLToPath, URL } from 'node:url' import { defineConfig } from 'vite' import vue from '@vitejs/plugin-vue' // https://vite.dev/config/ export default defineConfig({ resolve: { alias: { '@': fileURLToPath(new URL('./src', import.meta.url)) } }, plugins: [ vue({ template: { compilerOptions: { // 如果子应用中嵌套了 标签,需要注册为自定义元素 isCustomElement: (tag) => /^micro-app/.test(tag) } } }) ], // 子应用 base 路径,与主应用的 baseroute 保持一致 // base: '/vue3-app/', server: { port: 3001, // 允许主应用跨域请求子应用资源 headers: { 'Access-Control-Allow-Origin': '*' } } })