-
Notifications
You must be signed in to change notification settings - Fork 1
/
next.config.js
59 lines (51 loc) · 1.61 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
// eslint-disable-next-line @typescript-eslint/no-var-requires
const withNx = require('@nrwl/next/plugins/with-nx');
const { withFederatedSidecar } = require('@module-federation/nextjs-mf');
let merge = require('webpack-merge');
/**
* @type {import('@nrwl/next/plugins/with-nx').WithNxOptions}
**/
const nextConfig = {
nx: {
// Set this to true if you would like to to use SVGR
// See: https://github.com/gregberge/svgr
svgr: false,
},
webpack5: true,
webpack(config, options) {
const { isServer } = options;
config.experiments = { topLevelAwait: true };
config.module.rules.push({
test: /_app.tsx/,
loader: '@module-federation/nextjs-mf/lib/federation-loader.js',
});
if (isServer) {
// ignore it on SSR, realistically you probably wont be SSRing Fmodules, without paid support from @ScriptedAlchemy
Object.assign(config.resolve.alias, {
checkout: false,
store: false,
});
}
return merge.merge(config, {
entry() {
return config.entry().then(entry => {
return entry;
});
},
});
},
};
const nxNextConfig = withNx(nextConfig)
module.exports = withFederatedSidecar({
name: 'checkout',
filename: 'static/chunks/remoteEntry.js',
remotes: {
store: `store@${process.env.NEXT_PUBLIC_STORE_URL}/_next/static/chunks/remoteEntry.js`,
checkout: `checkout@${process.env.NEXT_PUBLIC_CHECKOUT_URL}/_next/static/chunks/remoteEntry.js`,
},
exposes: {
'./buy-button': './components/buy-button/buy-button.tsx',
'./useAddToCartHook': './hooks/useAddToCart.ts',
},
shared: {},
})(nxNextConfig);