A Step-by-Step Guide
Step-by-Step Guide to Build a Micro-frontend Architecture for a Super App
bashCopy codenpx create-nx-workspace super-appbashCopy codenpx create-react-app microfrontend-a --template typescript npx create-react-app microfrontend-b --template typescript npx create-react-app microfrontend-c --template typescriptbashCopy codenpm install @mui/material @emotion/react @emotion/styled
bashCopy codenpm install webpack webpack-cli webpack-dev-server webpack-merge @module-federation/webpack-federation-pluginjavascriptCopy codeconst ModuleFederationPlugin = require("@module-federation/webpack-federation-plugin"); module.exports = { mode: "development", devServer: { port: 3001 }, // Replace with unique port for each app plugins: [ new ModuleFederationPlugin({ name: "microfrontendA", // Change for each app filename: "remoteEntry.js", exposes: { "./Widget": "./src/Widget", // Component to expose }, shared: { react: { singleton: true }, "react-dom": { singleton: true } }, }), ], };javascriptCopy codenew ModuleFederationPlugin({ name: "container", remotes: { microfrontendA: "microfrontendA@http://localhost:3001/remoteEntry.js", microfrontendB: "microfrontendB@http://localhost:3002/remoteEntry.js", microfrontendC: "microfrontendC@http://localhost:3003/remoteEntry.js", }, });javascriptCopy codeimport WidgetA from "microfrontendA/Widget"; import WidgetB from "microfrontendB/Widget"; import WidgetC from "microfrontendC/Widget";
Last updated