-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
/
Copy pathnext.config.js
33 lines (32 loc) · 968 Bytes
/
next.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
const NextFederationPlugin = require('@module-federation/nextjs-mf');
// this enables you to use import() and the webpack parser
// loading remotes on demand, not ideal for SSR
const remotes = isServer => {
const location = isServer ? 'ssr' : 'chunks';
return {
shop: `shop@http://localhost:3002/_next/static/${location}/remoteEntry.js`,
checkout: `checkout@http://localhost:3000/_next/static/${location}/remoteEntry.js`,
};
};
module.exports = {
webpack(config, options) {
config.plugins.push(
new NextFederationPlugin({
name: 'home',
filename: 'static/chunks/remoteEntry.js',
dts: false,
exposes: {
'./nav': './components/nav.js',
'./home': './pages/index.js',
'./pages-map': './pages-map.js',
},
remotes: remotes(options.isServer),
shared: {},
extraOptions: {
exposePages: true,
},
}),
);
return config;
},
};