const ModuleFederationPlugin = require("webpack/lib/container/ModuleFederationPlugin");
|
|
const mf = require("@angular-architects/module-federation/webpack");
|
|
const path = require("path");
|
|
const share = mf.share;
|
|
|
|
const sharedMappings = new mf.SharedMappings();
|
|
sharedMappings.register(path.join(__dirname, "tsconfig.json"), [
|
|
]);
|
|
|
|
module.exports = {
|
|
output: {
|
|
uniqueName: "mef2",
|
|
publicPath: "auto",
|
|
},
|
|
optimization: {
|
|
runtimeChunk: false,
|
|
},
|
|
resolve: {
|
|
alias: {
|
|
...sharedMappings.getAliases(),
|
|
},
|
|
},
|
|
plugins: [
|
|
new ModuleFederationPlugin({
|
|
name: "mfe2",
|
|
filename: "remoteEntry.js",
|
|
exposes: {
|
|
"./Module1": "./src/app/microfrontend1/microfrontend1.module.ts",
|
|
},
|
|
shared: share({
|
|
'assets/img': { eager: true },
|
|
"@angular/core": {
|
|
singleton: true,
|
|
strictVersion: true,
|
|
requiredVersion: "auto",
|
|
},
|
|
"@angular/common": {
|
|
singleton: true,
|
|
strictVersion: true,
|
|
requiredVersion: "auto",
|
|
},
|
|
"@angular/common/http": {
|
|
singleton: true,
|
|
strictVersion: true,
|
|
requiredVersion: "auto",
|
|
},
|
|
"@angular/router": {
|
|
singleton: true,
|
|
strictVersion: true,
|
|
requiredVersion: "auto",
|
|
},
|
|
'my-shared': {
|
|
singleton: true,
|
|
strictVersion: true,
|
|
import: 'my-shared', // 对应库的npm包名或本地路径
|
|
requiredVersion: '*' // 或者具体的版本号,如"0.0.1"
|
|
},
|
|
...sharedMappings.getDescriptors(),
|
|
}),
|
|
}),
|
|
sharedMappings.getPlugin(),
|
|
],
|
|
};
|