Nest.js app using React and resources for server-side rendering
P粉134288794
P粉134288794 2024-03-26 00:30:02
0
1
357

Because I have a bit of a misunderstanding of the core principles of server rendering, there is no code.

I have:

Nest.js is configured with Handlebars. It is built using TypeScript out of the box. I don't use webpack here. I also created a separate folder that contains the client portion of my application. React, webpack, etc. are already configured and working fine.

I need to create a server render. For this I use ReactDOMServer. Everything works fine except when encountering SVG components and CSS modules.

This is my question - how to deal with it? What is the correct approach? Should I copy the webpack configuration on the server side (referring to resources), or is there a way to make it work with TypeScript (npm run build)?

thank you for your help!

P粉134288794
P粉134288794

reply all(1)
P粉237029457

You need to provide static resource files https://docs.nestjs.com/recipes/serve-static

You need to install @nestjs/serve-static

imports: [
  ServeStaticModule.forRoot({
    rootPath: join(__dirname, 'directory') // 文件路径,
  }),
],
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!