-
Notifications
You must be signed in to change notification settings - Fork 1
/
next.config.js
69 lines (64 loc) · 1.8 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
const { withFederatedSidecar } = require('@module-federation/nextjs-ssr');
const withPlugins = require('next-compose-plugins');
const name = 'shell';
const exposes = {
'./home': './realPages/index.tsx',
'./foo': './realPages/foo.tsx',
'./faq': './realPages/faq/index.tsx',
'./faqDetails': './realPages/faq/[...slug].tsx',
'./pages-map': './pages-map.ts',
};
const remotes = (isServer) => {
const location = isServer ? 'ssr' : 'chunks';
return {
shell: process.env.VERCEL_URL
? `shell@https://module-federation-nextjs-ssr-example.vercel.app/_next/static/${location}/remoteEntry.js?`
: `shell@http://localhost:3000/_next/static/${location}/remoteEntry.js?`,
ui: process.env.VERCEL_URL
? `ui@https://module-federation-nextjs-ssr-ui.vercel.app/_next/static/${location}/remoteEntry.js?`
: `ui@http://localhost:3003/_next/static/${location}/remoteEntry.js?`,
};
};
const nextConfig = {
env: {
VERCEL: process.env.VERCEL,
VERCEL_URL: process.env.VERCEL_URL,
},
webpack(config, options) {
const { webpack, isServer } = options;
config.module.rules.push({
test: [/_app.[jt]sx?/, /_document.[jt]sx?/],
loader: '@module-federation/nextjs-ssr/lib/federation-loader.js',
});
return config;
},
};
module.exports = withPlugins(
[
withFederatedSidecar(
{
name: name,
filename: 'static/chunks/remoteEntry.js',
exposes: exposes,
remotes: remotes,
shared: {
lodash: {
import: 'lodash',
requiredVersion: require('lodash').version,
singleton: true,
},
'use-sse': {
singleton: true,
},
},
},
{
experiments: {
flushChunks: true,
hot: true,
},
}
),
],
nextConfig
);