Skip to content

Commit 21c2fb9

Browse files
authored
fix(modern-js-plugin): apply ssr.distOutputDir in bundlerChain (#3675)
1 parent 64a2bc1 commit 21c2fb9

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

.changeset/soft-islands-protect.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@module-federation/modern-js': patch
3+
---
4+
5+
fix(modern-js-plugin): apply ssr.distOutputDir in bundlerChain

packages/modernjs/src/cli/ssrPlugin.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,10 @@ const mfSSRRsbuildPlugin = (
7070
? pluginOptions.userConfig.ssr
7171
: {}
7272
: {};
73-
config.output!.publicPath = `${config.output!.publicPath}${userSSRConfig.distOutputDir || path.relative(csrOutputPath, ssrOutputPath)}/`;
73+
if (userSSRConfig.distOutputDir) {
74+
return;
75+
}
76+
config.output!.publicPath = `${config.output!.publicPath}${path.relative(csrOutputPath, ssrOutputPath)}/`;
7477
return config;
7578
};
7679
api.modifyWebpackConfig((config, utils) => {
@@ -148,6 +151,17 @@ export const moduleFederationSSRPlugin = (
148151
.plugin('UniverseEntryChunkTrackerPlugin')
149152
.use(UniverseEntryChunkTrackerPlugin);
150153
}
154+
const userSSRConfig = pluginOptions.userConfig.ssr
155+
? typeof pluginOptions.userConfig.ssr === 'object'
156+
? pluginOptions.userConfig.ssr
157+
: {}
158+
: {};
159+
const publicPath = chain.output.get('publicPath');
160+
if (userSSRConfig.distOutputDir && publicPath) {
161+
chain.output.publicPath(
162+
`${publicPath}${userSSRConfig.distOutputDir}/`,
163+
);
164+
}
151165
}
152166

153167
if (isDev && isWeb) {

0 commit comments

Comments
 (0)