JLGH42 / marvel-app

0 stars 0 forks source link

Initialise the client #10

Open JLGH42 opened 3 months ago

JLGH42 commented 3 months ago

The code for the client UI needs to be rendered from the server in order to perform SSR (Server-side rendering):

Webpack: for converting JSX/JS code into language that the browser can understand Babel: Transforming and compiling code into one format, also reading extension files

~This also introduces the concept of hydration in React Apps: https://levelup.gitconnected.com/how-to-render-react-app-using-express-server-in-node-js-a428ec4dfe2b~

  1. Initialise the project: setup Webpack and Babel to read and write to the index file
  2. Use Babel to compile code into the build file which is rendered on the server
  3. Build out a simple component to view inside of the browser and ensure SSR is being used

Because ExpressJS already has the capability to serve static files, I can take advantage of this by restructuring the project setup and using Express to serve the "build" folder once in production.

The objectives are:

Pros:

Cons:

JLGH42 commented 2 months ago
JLGH42 commented 2 months ago

To render to the App component:

  1. run npm run build
  2. place the generated 'build' folder into the server's "public" folder