This boilerplate example allows you to create React universal application:
JS Off (server-side render) | JS On (client-side render) |
---|---|
> git clone https://github.com/gzoreslav/react-redux-saga-universal-application.git
> cd react-redux-saga-universal-application
> npm i
Note: You may have to install nodemon and babel-cli globally
> npm i nodemon -g
> npm i babel-cli -g
There are few options for launch:
> npm run start-dev-iso
It builds app.bundle.js in dev mode and runs dev universal server with HMR and opens Browser
Name | Value |
---|---|
Port | 3030 |
Open Browser | no |
Build client.bundle.js | yes, in dev mode |
Copy resources (fonts, css, images, etc.) to dist | yes |
Build server.bundle.js | no |
HMR for client.bundle.js | yes |
HMR for server.bundle.js | yes |
Server Rendering | yes |
> npm run start-dev-client
It runs dev server with HMR and opens Browser
Name | Value |
---|---|
Port | auto |
Open Browser | yes |
Build client.bundle.js | no |
Copy resources (fonts, css, images, etc.) to dist | no |
Build server.bundle.js | no |
HMR for client.bundle.js | yes |
HMR for server.bundle.js | no |
Server Rendering | no |
You have to build client first and build server then.
> npm run build-prod-client
It builds app.bundle.js in production mode and copies resources to dist folder
Name | Value |
---|---|
Port | - |
Open Browser | no |
Build client.bundle.js | yes, in prod mode |
Copy resources (fonts, css, images, etc.) to dist | yes |
Build server.bundle.js | no |
HMR for client.bundle.js | no |
HMR for server.bundle.js | no |
Server Rendering | - |
> npm run build-prod-server
It builds server.bundle.js in production mode
Name | Value |
---|---|
Port | 3030 |
Open Browser | no |
Build client.bundle.js | no |
Copy resources (fonts, css, images, etc.) to dist | no |
Build server.bundle.js | yes, in prod mode |
HMR for client.bundle.js | no |
HMR for server.bundle.js | no |
Server Rendering | yes |
> npm run start-prod-iso
It launch server.bundle.js built in the previous steps
Copy package.json to the server
> npm install
NOTE: We do steps above, because _nodemodules are not included into built server.bundle.js. So, that's why we need _nodemodules folder on the server.
> npm run build-prod-client
> npm run build-prod-server
Copy dist folder to the server
> npm run start-prod-iso
I am always open to your feedback.
This software is distributed under an MIT licence.
Copyright 2017-2018 © Zoreslav Goral