cd ./node-react-babel-stack
,
npm install
cd ./server
npm install
cd ./frontend
npm install
Frontend files are contained in the frontend/src
directory.
Server files are contained in server/
.
!! Probably a better way to handle this but havem't had time to figure it out yet, pull requests welcome.
-
Run
npm run frontend-dev-build
, this will copy index.html to the dist folder for express to mount. -
Run
npm run frontend-dev-server
-
Run
npm run server
ornpm server-watch
(included nodemon).
npm run frontend-prod-build
After doing this you are free to run your node server without the separate dev server, it will just grab the bundle from the dist folder.
- Paths to static files should be prefixed with
{%=o.htmlWebpackPlugin.options.assetPath%}
- Changes to index.html will require an
npm-frontend-dev-build
to be reflected.
The frontend server and the node server have to run on different ports in development.
To change the ports for the frontend server please go to:
/frontend/webpack.config.dev.js
and replace any instance of https://localhost:8080 with the path to your preferred url (must be full url).
You will also need to change the path specified in the index.html file for bundle.js to match it.
To change port for the express server run with PORT=YOUR-PORT-HERE npm run server