Last active
May 23, 2024 05:43
-
-
Save amir2mi/c9fd7b657d148ff5355039c1207a3015 to your computer and use it in GitHub Desktop.
Setup module federation for Next.js using @module-federation/nextjs-mf
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const nextJsConfig = { | |
webpack(config, options) { | |
if (!options?.isServer) { | |
config.plugins.push( | |
new NextFederationPlugin({ | |
name: "service-name", | |
filename: "static/chunks/remoteEntry.js", | |
exposes: { | |
"./pages/index": "./pages/index.jsx", | |
}, | |
shared: { | |
zustand: { | |
singleton: true, | |
}, | |
antd: { | |
singleton: true, | |
}, | |
redux: { | |
singleton: true, | |
}, | |
}, | |
extraOptions: { | |
enableUrlLoaderFix: true, | |
enableImageLoaderFix: true, | |
}, | |
}) | |
); | |
} | |
}, | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment