React.js application which represents the entire browser-side client. File structure is standard for a create-react-app application with some minor changes. Any component which represents an entire page is categorized under the views folder.
- Install Node and Yarn
- Run
yarn
to install project dependencies - Run
yarn start
to startup the client (please note that much of the functionality will not work without also starting up the backend services) - Navigate to chrome://flags/ and enable the #enable-experimental-web-platform-features flag (This will provide your browser access to serial ports)
This react project has the following file structure rules:
- Routing is handled from client root in
App.js
, rendered in react byindex.js
- Components which render as a page are generally listed under the
/views
folder - Component styling is placed into a folder under the name of the main component alongside the component and sub-component files.
- As an example the folder
/Home
contains theHome.js
component, theHome.css
styling, and a couple of sub-components.
- As an example the folder
/Utils
contains additional utility functions like different database requests or authentication handlers
All client routes are handled by react router. The index.html file and all static assets will be served by the server.
In the project directory, you can run:
Runs the app in the development mode. Open http://localhost:3000 to view it in the browser.
Stars a basic http server (using http-server) which serves the build folder on http://localhost:3000 .
Builds the app for production to the build
folder.
It correctly bundles React in production mode and optimizes the build for the best performance.
To maintain a consistant theme the folowing has been implemented in \client\src\assets\style.less
for import
primary: #3D5C82;
secondary: #5BABDE;
tertiary: #F4F4F5;
text-primary: #414141;
text-secondary: #FFFFFF;
Section on fixing issue where yarn build does not minify: https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify
Section on code splitting, worth considering at some point: https://facebook.github.io/create-react-app/docs/code-splitting