This project is based on Create React App with some other pre-configured libraries and packages to facilitate the boring process of starting a project.
This is a boilerplate which is supposed to be a starter template for front-end teams of Mofid Securities company.
Note: This branch DOES NOT support TypeScript, If you wanna have TypeScript support, use
typescript
branch.
- Installed Packages
- Important Configs and Notes
- Boilerplate Structure
- Common Available Scripts
- New Available Scripts
- Learn More
This project has some installed packages. Here is the list of them:
axios
as HTTP clientreact-responsive
withuseDevice
hookreact-router-dom
react-helmet
dayjs
withjalaliday
as jalali and georgian date packagepersian-tools2
as persian utility library@sentry/react
as bug and performance tracking library (service)
redux
react-redux
redux-saga
redux-logger
redux-devtools-extension
ant-design
styled-components
react-hook-form
eslint
withreact-app
,airbnb
andprettier
confighusky
withlint-staged
which is configured based oneslint
andprettier
cross-env
(to solve env var issue between OSs)
jest
as test runner@testing-library/react
as React DOM testing utilites.
Note: Altough we haven't config any API mocking library, but it's recommended to use
msw
for this purpose and not usingfetch
or other real http client for testing APIs.
-
craco
is installed to customize webpack configs. -
As it's mentioned earlier, this branch doesn't support TypeScript, but there is a
typescript
branch that supports it. -
The boilerpalte supports
Less
. It's configured incraco.config.js
. -
absolute path has configured in
craco.config.js
(webpack config),jsconfig.json
(IDE config) andeslintrc.js
(ESLint config) (e.g.,@utils
path points to./src/utils
directory). this config prevents relative path hell! -
husky
withlint-stages
is configured in the boilerplate which runseslint
andprettier
commands as gitpre-commit
command. -
The boilerplate uses
CRLF
as default end-of-line format. It's configured ineslintrc.js
,eslintrc.js
and prettier config inpackage.json
. (Constant end-of-line format is better than tormenting inconsistencies. 😉). You may want to configure your IDE default end-of-line format manually.vscode
end-of-line is configured in.vscode/settings.json
-
The boilerplate uses
kebab-case
as default file-naming convension.
There is a index.js
file which contains axios interceptor. You can config axios and maniputlate request and response with interceptor.
All componennts are there, such as customized antd
components with styled-components
which exist in customized
directory.
Each component directory, could have a __test__
directory beside itself and all test files related to that component can be added there.
all constants file exect store constants exist in constants
directory such as general routing path and width constants
Hooks of project should be added to this direcotry. There is a common useDevice
hook in this directory.
this hook uses react-responsive
under the hood and provide some properties which can be used to determine the user device resolution and make decision based on them.
All pages of the app should be added here. main pages categories specifes with directory name (such as app.com/samples
)
Each page directory, could have a __test__
directory beside itself and all test files related to that page can be added there.
Also all reducers
, actions
, sagas
and constants
files related to a page, exist in its own directory (checkout an example in ./src/pages/auth/auth
).
store configuration, root reducer and root saga is here.
General utility functions should be added to this directory.
This file configs dayjs
with jalaliday
as jalali plugin for it. Also contains some utility functions of them.
In the project directory, you can run:
Runs the app in the development mode.
Open http://localhost:3000 to view it in the browser.
The page will reload if you make edits.
You will also see any lint errors in the console.
Launches the test runner in the interactive watch mode.
See the section about running tests for more information.
Builds the app for production to the build
folder.
It correctly bundles React in production mode and optimizes the build for the best performance.
The build is minified and the filenames include the hashes.
Your app is ready to be deployed!
See the section about deployment for more information.
Note: this is a one-way operation. Once you eject
, you can’t go back!
If you aren’t satisfied with the build tool and configuration choices, you can eject
at any time. This command will remove the single build dependency from your project.
Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except eject
will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.
You don’t have to ever use eject
. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.
run eslint
on all files of src
directory which ends with js
, jsx
and json
run eslint
on whole project with --fix
option.
run prettier
on all files of src
directory.
You can learn more in the Create React App documentation.
To learn React, check out the React documentation.
This section has moved here: https://facebook.github.io/create-react-app/docs/code-splitting
This section has moved here: https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size
This section has moved here: https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app
This section has moved here: https://facebook.github.io/create-react-app/docs/advanced-configuration
This section has moved here: https://facebook.github.io/create-react-app/docs/deployment
This section has moved here: https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify