vue3子应用搭建完成
This commit is contained in:
31
vite.config.ts
Normal file
31
vite.config.ts
Normal file
@@ -0,0 +1,31 @@
|
||||
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: {
|
||||
// 如果子应用中嵌套了 <micro-app> 标签,需要注册为自定义元素
|
||||
isCustomElement: (tag) => /^micro-app/.test(tag)
|
||||
}
|
||||
}
|
||||
})
|
||||
],
|
||||
// 子应用 base 路径,与主应用的 baseroute 保持一致
|
||||
base: '/vue3-app/',
|
||||
server: {
|
||||
port: 3001,
|
||||
// 允许主应用跨域请求子应用资源
|
||||
headers: {
|
||||
'Access-Control-Allow-Origin': '*'
|
||||
}
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user