-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
/
Copy pathnext.config.js
46 lines (45 loc) · 1.2 KB
/
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
34
35
36
37
38
39
40
41
42
43
44
45
46
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 {
home: `home@http://localhost:3001/_next/static/${location}/mf-manifest.json`,
shop: `shop@http://localhost:3002/_next/static/${location}/mf-manifest.json`,
};
};
module.exports = {
headers() {
return [
{
source: '/_next/static/chunks/mf-manifest.json',
headers: [
{
key: 'Access-Control-Allow-Origin',
value: '*',
},
],
}
]
},
webpack(config, options) {
config.plugins.push(
new NextFederationPlugin({
name: 'checkout',
filename: 'static/chunks/remoteEntry.js',
dts: false,
exposes: {
'./title': './components/exposedTitle.js',
'./checkout': './pages/checkout.js',
'./pages-map': './pages-map.js',
},
remotes: remotes(options.isServer),
shared: {},
extraOptions: {
exposePages: true,
},
}),
);
return config;
},
};