- This is an useful, developer-friendly React SPA Infrastructure template.
- It already set up lots of configuration while all of them are exposed and can be easily replaced upon requirement.
- It makes both commands and configurations as easy & light as possible.
- It includes few resources (e.g. reboot.scss, background image etc.) as template. Feel free to modify or remove them.
- Windows environment is recommended.
- You can use this repository as a fundamental architecture to easily start your React SPA asap.
Pattern
node do [command] [option1[=value1]] [option2[=value2]] ...
For example:
node do server
node do server nolint prod port=8008
node do lint
node do lint fix
- This command is used to start/test server & application under various environment/conditions.
- It will show current configuration information in terminal and automatically open new tab in your default browser.
- The application is available on both
localhost:[port]
and your LAN (e.g.192.168.1.100:[port]
).
OPTION | VALUE | DESCRIPTION | DEFAULT |
---|---|---|---|
nolint | N/A | disable the ES linter | linter is enabled |
prod | N/A | switch to production environment | development environment |
port | Integer | run application in given port number | port=3000 |
- This command is used to automatically format all existing
*.{js|jsx}
files undersrc
folder. - It actually takes advantage of Prettier
- Beside this manual command, formatting will also be done automatically once you push any commit thanks to a pre-commit hook attached.
- Although when you start the application, you can view all lint warnings in browser console, however we also provide alternative to check your syntax & best practice problems in more straightforward way.
- By Using this command, it will output all lint warnings in your terminal directly. The application won't start a local server to run this application in order to save resource/memory.
OPTION | VALUE | DESCRIPTION | DEFAULT |
---|---|---|---|
fix | N/A | it will try to fix as many warnings as possible | just show warnings info without trying to fix |
The built-in pre-commit hook will automatically use both eslint and prettier to fix part of code styles / best practice issues before your commit (e.g. git add-commit
).
If it detects any error instead of warnings then the commit will be prevented.
Thanks to lint-staged, your commit and auto-fix commit will be merged into one commit.
Reference
Please feel free to configure it to suit your preference.
- Create a bundle file containing all necessary resources.
- Media resources like images will be created separately.
- All created files are under
assets
folder. - Once created, you can directly open
assests/index.html
in your browser without a local server.
- In the
src/scripts/.eslintrc.json
file, we included not only all rules covered by eslint:recommended and plugin:react/recommended, but also lots of extra rules. - Please refer them before you make any PR and any contributions. Before merging your PR, you must clear all the linter warnings & errors!.
- You are welcome to share your opinion about enhancing code styles and best practices.
- In the
.github/workflows
directory, there is an included template file namedmain.yml
which introduced basic checks each time when apush
action is taken. - GitHub will automatically runs 3 checks introduced (install, prettier, eslint), and you are strongly recommended to make sure all checks passed before you start to merge.