DEV Community

Chamil Ananda
Chamil Ananda

Posted on

Adding modulefederation plugin to comfig-overrides.js

Hi Guys Can some one guid me to integrate module fedartion plugin with config-override.js.
I have bellow code
const rewireReactHotLoader = require('react-app-rewire-hot-loader');
const ModuleFederationPlugin = require("webpack/lib/container/ModuleFederationPlugin");

module.exports = function override(config, env) {
config = rewireReactHotLoader(config, env);

config.resolve.alias = {
...config.resolve.alias,
'react-dom': '@hot-loader/react-dom',
};
config.plugins.push(
new ModuleFederationPlugin({
name: "CreateApp",
filename: "moduleEntry.js",
exposes: {
'./InclusiveAccessReportsList': './src/pages/InclusiveAccessReportsList"'
},
shared: {
...dependencies,
react: {
singleton: true,
requiredVersion: dependencies["react"],
},
"react-dom": {
singleton: true,
requiredVersion: dependencies["react-dom"],
},
"react-router-dom": {
singleton: true,
},
},
})
)

return config;
};
Is this the correct way to do this..For me this gives an error

Top comments (0)