Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add Rsbuild SSR express with manifest example #178

Merged
merged 1 commit into from
Nov 27, 2024

Conversation

9aoy
Copy link
Contributor

@9aoy 9aoy commented Nov 27, 2024

In some cases, the user's html is provided on the server side, and the manifest of script and link needs to be obtained and injected into the html. Grouped manifests can be easily obtained using the output.manifest configuration.

  const { entries } = JSON.parse(fs.readFileSync('./dist/manifest.json', 'utf-8'));

  const { js, css } = entries['index'].initial;

  const scriptTags = js.map(file => `<script src="${file}" defer></script>`).join('\n');
  const styleTags = css.map(file => `<link rel="stylesheet" href="${file}">`).join('\n');  

  const html = templateHtml.replace('<!--app-head-->', `${scriptTags}\n${styleTags}`);

@9aoy 9aoy requested a review from chenjiahan November 27, 2024 03:21

const markup = indexModule.render();

const { entries } = JSON.parse(fs.readFileSync('./dist/manifest.json', 'utf-8'));
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should support await serverAPI.environments.web.readFile("manifest.json") API?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, we can design a new API for this scenario.

@chenjiahan chenjiahan changed the title feat: add rsbuild ssr express with manifest example feat: add Rsbuild SSR express with manifest example Nov 27, 2024
@chenjiahan chenjiahan merged commit 5b6cee3 into rspack-contrib:main Nov 27, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants