Simple example of how to do server-rendering. You will not believe how easy it is!
npm run dev- Run the development server with hot reload but no server-rendering
npm run build- Build for production, required before running
npm start- Start the production server
To do proper server-rendering, the code is bundled in two version: one for the browser and one for Node.js.
The browser version is in the
dist/client folder and the Node.js version is in
dist/server. However, they both share the same public path for their files:
/dist and it points to the browser version. Go read the code, it's pretty straightforward!
scriptssection to understand how the build process works. Yes it's that dead simple!
index.htmlas the template with cheerio