A template to get start coding quickly. Use react front-end framework with the very powerful yet difficult to configure bundler, webpack. Yarn@berry is more powerful than npm, because of the cache system and meaningful colored logs.
- 🚀 Ready to use with the boring stuff setup for you
- 📦 Minimal webpack configuration
- 📖 Storybook
- 🌐 Internationalization with react-i18next
- 🔍 Linting with eslint and stylelint
- ✨️ Formatting with prettier
- 🎣 Git hooks to format and lint features in each commit
- 🏗️ Github action to lint and test (comming soon insha'Allah)
- 😁 Easy import with
import Button from "_components/Button"
instead ofimport Button from "../../../components/Button"
command | description |
---|---|
yarn dev |
start webpack server |
yarn prod |
build in production mode |
yarn analyze |
analyze your production bundle and get packages statistics |
yarn lint |
eslint |
yarn slint |
stylelint |
yarn format |
prettier |
yarn storybook |
start-storybook |
We are using webpack@5 as the bundler for this project, the SCSS-CSS loader is by default enables what so called CSS modules. For example I use a CSS module for the Button component. The reason to notice this type of CSS file, the CSS modules, is to make the somponent classes scoped only to the Button and not to the global scope (the whole page). This reduces the unexpected errors and "Why it is not working?!". The second reason is that it is cool ✨️.
One of the reason to use git hooks in this project is that we are using hooks in React as well :D
Git hooks are hooked using husky. When you git commit
, the pre-commit hook will start its job to prettier the stuff you made, eslint them as well, using lint-staged.
✔ Preparing...
✔ Running tasks...
✔ Applying modifications...
✔ Cleaning up...
In order to make all these gears engage together
- some customized webpack configs are used for storybook, e.g., SCSS-CSS loader.
- I am using the same i18next config for storybook.
You need to customize git hooks config to match your desires.
- your
./git-hooks/pre-commit
#!/bin/sh
cd path/to/frontend
# ...
- postintall script
"postintall": "git config --local core.hooksPath path/to/frontend/.git-hooks || echo \"failed to hook the git hooks\"",
MIT