- Make sure that you have Node.js v8.15.1 and npm v5 or above installed.
- Clone this repo using
git clone https://github.com/kaushalshah-98/react-boilerplate.git <YOUR_PROJECT_NAME>
- Move to the appropriate directory:
cd <YOUR_PROJECT_NAME>
. - Run
npm run install
in order to install dependencies.
At this point you can runnpm start
to see the example app athttp://localhost:8090
.
Now you're ready to rumble!
Please note that this boilerplate is production-ready and not meant for beginners!. If you want a solid, battle-tested base to build your next product upon and have some experience with react, this is the perfect start for you.
You don’t need to install or configure tools like webpack or Babel.
They are preconfigured so that you can focus on the code.
- Quick scaffolding
- Create components, pages, - right from the CLI!
- Instant feedback
- Enjoy the best DX (Developer eXperience) and code your app at the speed of thought! Your saved changes to the CSS and TS are reflected instantaneously without refreshing the page. Preserve application state even when you update something in the underlying code!
- Scalable and Simple state management
- Unidirectional data flow allows for change logging.
- Next generation JavaScript
- Use template strings, object destructuring, arrow functions, JSX syntax and more.
- Next generation CSS
- Write composable CSS in css, scss or utiltity tailwind classes. Tailwind CSS A utility-first CSS framework for rapidly building custom user interfaces
- Industry-standard routing
- It's natural to want to add pages (e.g. `/about`) to your application, and routing makes this possible.
- Offline-first
- The next frontier in performant web apps: availability without a network connection from the instant your users load the app.
- Static code analysis
- Focus on writing new features without worrying about formatting or code quality. With the right editor setup, your code will automatically be formatted and linted as you work.
- Industry-standard Testing
- Allows to create tests in typescript and you can use enzume, jest and react-test-renderer all to simplify your testing, It also provides you with coverage report
- Ready for any Environment
- It is ready to work with any environment such as Development, Production and staging and all can have their different `.env` files
- Path alias
- Create a path alias in `tsconfig.json` and it will allow to find a file or resource located in a different directory or folder from the place where the shortcut is located.
- Webpack Config paths based on your file structure you can go to
webpack/paths.js
and modify the source and file names based on your need. webpack/webpack.common.js
config common webpack for both dev and production environments.- webpack/webpack.dev.js config webpack for dev environment.
webpack/webpack.prod.js
config webpack for production environment./webpack.config.js
main webpack config that merge common and webpack environment based config.- Enzyme config
/setupTest.ts
here you will have all setup for enzyme to test your component. - Prettier config
/.prettierc
. - Jest config
/jest.config.js
. - Tailwind config
/tailwind.config.js
. - Postcss config
/postcss.config.js
. - Typescript config
/tsconfig.json
. - Generate React CLI config
/.browserslistrc
. - ESLint config
/.eslintrc.js
. - Babel config
/.babelrc
.
There are total 12 Scripts in total
To start in development mode, run the following command
npm run start
To build the code, run the following command
npm run build
To build tailwind css, run the following command
npm run build-tailwind
To run tests, run the following command
npm run test
To run tests with coverage, run the following command
npm run test:coverage
To open coverage report, run the following command
npm run open:coverage
To prettify code, run the following command
npm run prettify
To check lint erros, run the following command
npm run lint
To fix auto fixable lint erros, run the following command
npm run lint-fix
To generate a new component, run the following command
npm run gen-comp <ComponentName>
To generate a new page, run the following command
npm run gen-page <PageName>
To commit your changes, run the following command
npm install -g commitizen cz-conventional-changelog git-cz
npm run commit
│───__mocks__
│ └──────────────────────────────────────────────────────── # Mocks
├───.husky
│ └──────────────────────────────────────────────────────── # Husky hooks
├───.vscode
│ └──────────────────────────────────────────────────────── # VS Code Settings
│ └───extensions.json
│ └───launch.json
│ └───settings.json
├───config
│ └──────────────────────────────────────────────────────── # Global configs
├───dist
│ └──────────────────────────────────────────────────────── # Production Build
├───coverage
│ └──────────────────────────────────────────────────────── # Coverage Report
├───env
│ └──────────────────────────────────────────────────────── # Environment files
│ └───.env.production
│ └───.env.staging
│ └───.env.local
│ └───.env.development
│
├───public
│ └──────────────────────────────────────────────────────── # Public
│ └───assets
│
├───webpack
│ ├──────────────────────────────────────────────────────── # webpack Configs
│ ├─── paths.js
│ ├───webpack.common.js
│ ├───webpack.dev.js
│ └───webpack.prod.js
├───src
│ │───api
│ │ │─────────────────────────────────────────────────── # All api's
│ │ │───api1
│ │ │ └───.index.ts
│ │ │───api1
│ │ │ └───.index.ts
│ │ │───apicaller.ts
│ │ └───index.ts
│ │
│ ├───components
│ │ ├──────────────────────────────────────────────────── # All Components
│ │ ├───ComponentName
│ │ │ ├───index.tsx
│ │ │ ├───ComponentName.css
│ │ │ └───ComponentName.test.tsx
│ │ │
│ ├───config
│ │ ├───────────────────────────────────────────────────── # Config
│ │ ├───constant.ts
│ │ └───globals.ts
│ │
│ ├───layouts
│ │ └───────────────────────────────────────────────────── # Layout
│ ├───libs
│ │ └───────────────────────────────────────────────────── # Libs
│ │ └───logger.ts
│ │
│ ├───pages
│ │ └───────────────────────────────────────────────────── # pages
│ │ └───PageName
│ │ └───index.tsx
│ ├───providers
│ │ └───────────────────────────────────────────────────── # providers
│ │ └───index.tsx
│ ├───routes
│ │ └───────────────────────────────────────────────────── # routes
│ │ ├───Protected.tsx
│ │ └───UnProtected.tsx
│ ├───shared
│ │ └──────────────────────────────────────────────────────# shared comonents
│ └───store
│ │ └──────────────────────────────────────────────────── # Store setup
│ │ ├───store1.ts
│ │ ├───store2.ts
│ │ ├───createStore.tsx
│ │ └───index.ts
│ │───utils
│ │ └───────────────────────────────────────────────────── # utils
│ ├───styles
│ │ └───────────────────────────────────────────────────── # Global styles
│ ├───setupTests.ts
│ │ └───────────────────────────────────────────────────── # Testsetup file
react
- JavaScript library for building user interfaces.react-dom
- React package for working with the DOM.react-router-dom
- DOM bindings for React Router
mobx
- Simple, scalable state management.mobx-react
- React bindings for MobX. Create fully reactive components.
emotion/react
- Simple styling in React.emotion/styled
- Styled API for emotionheadlessui/react
- A set of completely unstyled, fully accessible UI components for React, designed to integrate beautifully with Tailwind CSS.classnames
- A simple utility for conditionally joining classNames together
Logatim
- Isomorphic logger which implements log levels and ANSI stylesaxios
- Promise based HTTP client for the browser and node.js
webpack
- Module and asset bundler.webpack-cli
- Command line interface for webpackwebpack-dev-server
- Development server for webpackwebpack-merge
- Simplify development/production configuration
@babel/core
- Transpile ES6+ to backwards compatible JavaScript@babel/plugin-proposal-class-properties
- Use properties directly on a class (an example Babel config)@babel/preset-env
- Smart defaults for Babel@babel/runtime
- Babel's modular runtime helpers@babel/preset-react
- Babel preset for all React plugins.@babel/preset-typescript
- Babel preset for TypeScript
tailwindcss
- A utility-first CSS framework for rapidly building custom user interfaces.
jest
- Delightful JavaScript Testingenzyme
- Delightful JavaScript Testingreact-test-renderer
- React package for snapshot testing.@testing-library/jest-dom
- Custom jest matchers to test the state of the DOM@testing-library/react
- Simple and complete React DOM testing utilities@testing-library/user-event
- Fire events the same way the user doeswojtekmaj/enzyme-adapter-react-17
- Unofficial adapter for enzyme for React17
babel-loader
- Transpile files with Babel and webpacksass-loader
- Load SCSS and compile to CSSnode-sass
- Node Sasscss-loader
- Resolve CSS importspostcss-loader
- Loader to process CSS with PostCSSstyle-loader
- Inject CSS into the DOM
eslint-config-prettier
- Turns off all rules that are unnecessary or might conflict with Prettier.eslint-import-resolver-alias
- a simple Node behavior import resolution plugin for eslint-plugin-import, supporting module alias.eslint-plugin-babel
- an eslint rule plugin companion to babel-eslint.eslint-plugin-import
- This plugin intends to support linting of ES2015+ (ES6+) import/export syntax, and prevent issues with misspelling of file paths and import names.eslint-plugin-prettier
- Runs prettier as an eslint rule.eslint-plugin-react
- React specific linting rules for ESLint.eslint-plugin-react-hooks
- Enforces the Rules of React Hooks.
clean-webpack-plugin
- Remove/clean build folders
html-webpack-plugin
- Generate HTML files from templatemini-css-extract-plugin
- Extract CSS into separate files
react-refresh-webpack-plugin
- HMR using React Fast Refreshdotenv-webpack
- Supports dotenv and other environment variables
babel-jest
- Jest plugin to use babel for transformation.ts-jest
- A preprocessor with source maps support to help use TypeScript with Jest
Kaushal Shah |
Piyush Patel |
Shoaib Merchant |