Skip to content

Commit

Permalink
Issue-1118: Refactor rollup config generation for SSR
Browse files Browse the repository at this point in the history
  • Loading branch information
DevLab2425 committed Dec 4, 2023
1 parent 66128d6 commit 8fad6f7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
8 changes: 3 additions & 5 deletions packages/cli/src/config/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -383,10 +383,8 @@ const getRollupConfigForApis = async (compilation) => {
const getRollupConfigForSsr = async (compilation, input) => {
const { outputDir } = compilation.context;

// TODO should routes and APIs have chunks?
// https://github.com/ProjectEvergreen/greenwood/issues/1118
return [{
input,
return input.map(filepath => ({
input: filepath,
output: {
dir: normalizePathnameForWindows(outputDir),
entryFileNames: '_[name].js',
Expand Down Expand Up @@ -423,7 +421,7 @@ const getRollupConfigForSsr = async (compilation, input) => {

}
}
}];
}));
};

export {
Expand Down
10 changes: 6 additions & 4 deletions packages/cli/src/lifecycles/bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -235,11 +235,13 @@ async function bundleSsrPages(compilation) {
}
}

const [rollupConfig] = await getRollupConfigForSsr(compilation, input);
const ssrConfigs = await getRollupConfigForSsr(compilation, input);

if (rollupConfig.input.length > 0) {
const bundle = await rollup(rollupConfig);
await bundle.write(rollupConfig.output);
if (ssrConfigs.length > 0 && ssrConfigs[0].input.length > 0) {
ssrConfigs.forEach(async rollupConfig => {
const bundle = await rollup(rollupConfig);
await bundle.write(rollupConfig.output);
});
}
}
}
Expand Down

0 comments on commit 8fad6f7

Please sign in to comment.