完成 微前端拆分 提交遗漏文件
This commit is contained in:
50
front-end/app-product/vite.config.ts
Normal file
50
front-end/app-product/vite.config.ts
Normal file
@@ -0,0 +1,50 @@
|
||||
import { defineConfig } from 'vite';
|
||||
import vue from '@vitejs/plugin-vue';
|
||||
import vueJsx from '@vitejs/plugin-vue-jsx'
|
||||
import vueDevTools from 'vite-plugin-vue-devtools'
|
||||
import federation from '@originjs/vite-plugin-federation';
|
||||
import {fileURLToPath, URL} from "node:url";
|
||||
|
||||
export default defineConfig({
|
||||
plugins: [
|
||||
federation({
|
||||
name: 'productModule', // 联邦模块名称(主应用通过此名称引用)
|
||||
filename: 'remoteEntry.js',
|
||||
// 关键:声明远程模块(主模块)
|
||||
remotes: {
|
||||
mainApp: "http://localhost:5000/assets/remoteEntry.js"
|
||||
},
|
||||
exposes: { // 暴露给主应用的资源(按功能分组)
|
||||
'./ProductDomain': './src/domains/product/index.ts', // 领域层(实体、服务、接口等)
|
||||
'./ProductRouter': './src/features/product/router/index.ts' // 商品路由
|
||||
},
|
||||
shared: {
|
||||
vue: { generate:false, requiredVersion: '^3.5.18' },
|
||||
axios: { generate:false, requiredVersion: '^1.12.2' },
|
||||
'vue-router': { generate:false, requiredVersion: '^4.0.6' },
|
||||
pinia: { generate:false, requiredVersion: '^3.0.3' }
|
||||
}
|
||||
}),
|
||||
vue(),
|
||||
vueJsx(),
|
||||
vueDevTools()
|
||||
],
|
||||
build: {
|
||||
target: 'esnext',
|
||||
cssCodeSplit: true,
|
||||
rollupOptions: {
|
||||
output: {
|
||||
format: 'es',
|
||||
minifyInternalExports: false
|
||||
}
|
||||
}
|
||||
},
|
||||
resolve: {
|
||||
alias: {
|
||||
'@': fileURLToPath(new URL('./src/', import.meta.url)),
|
||||
'@shared': fileURLToPath(new URL('./src/shared/', import.meta.url)),
|
||||
'@features': fileURLToPath(new URL('./src/features/', import.meta.url)),
|
||||
'@domains': fileURLToPath(new URL('./src/domains/', import.meta.url))
|
||||
},
|
||||
},
|
||||
});
|
||||
Reference in New Issue
Block a user