🎉 Add simple React SSR(Server Side Rendering) support for your SPA app
also including the following changes:
✨Add LOG_PATH & ENABLE_SSR config
💾Change mw dir name to services
👢Use Bootstrap scss files for easy customization instead of the compiled one
✂️Remove webpack-dashboard, kind of slowing down the install process
✂️Simplify the index.html file, other assets or dynamic nunjucks template tags will be injected by webpack
How to enable:
First enable ENABLE_SSR: true in your app-config.js or env, also HMR should be disabled(maybe can use them together in the future) since we are using our own server logic to do SSR, also set STATIC_PREFIX to some not empty value, e.g /static, to prevent html error when access '/' home page, which is handle directly by static middleware without rendering by nunjucks.
You will need to use npm run watch(your client react app)
Use npm run ssr -- --watch to transpile the SSR related source code to be required in your node.js code, see routes/index.js
Use npm start(your koa server) to let the koa server do SSR stuff
Go to the browser to see the responsed html doc
TODOs
Use SSR Stream API
Need a cache policy for SSRed content
Universal React Route Config ?
Automatically restart koa server when ssr related code changed(with nodemon?) after ssr script rerunned
🎉 Add simple React SSR(Server Side Rendering) support for your SPA app
also including the following changes:
LOG_PATH
&ENABLE_SSR
configmw
dir name toservices
index.html
file, other assets or dynamic nunjucks template tags will be injected by webpackHow to enable:
ENABLE_SSR: true
in yourapp-config.js
or env, also HMR should be disabled(maybe can use them together in the future) since we are using our own server logic to do SSR, also setSTATIC_PREFIX
to some not empty value, e.g/static
, to prevent html error when access '/' home page, which is handle directly by static middleware without rendering by nunjucks.npm run watch
(your client react app)npm run ssr -- --watch
to transpile the SSR related source code to be required in your node.js code, seeroutes/index.js
npm start
(your koa server) to let the koa server do SSR stuffTODOs
nodemon
?) afterssr
script rerunned