Includes support for:
- React with TypeScript/JavaScript (preferably stick to TypeScript)
- ESLint with custom rules added from @badboyku/eslint-config-badboyku
- Jest with jest-dom
- Husky's pre-commit hook that will run linter and tests
- Webpack with Module Federation Plugin
- Install dependencies:
yarn installornpm install - Start the app:
yarn startornpm start- Browser should automatically open to http://localhost:8080
NOTE: App will be served from webpack-dev-server's default port 8080, which can be changed by following the .env.example in the repo.
This plugin is used to help bundle multiple builds into one build. There is a bootstrap.tsx file that is necessary for the plugin to work correctly.
WARNING: Do not remove file bootstrap.tsx
There are some options that need to be set in webpack.config.js file:
-
name- this is used for your application nameExample:
name: 'my_app' -
remotes- this is used to set up your app to have remote appsExample:
remotes: { this_app: 'this_app@http://localhost:8081/remoteEntry.js', that_app: 'that_app@http://localhost:8082/remoteEntry.js', } -
exposes- this is used to set up your app to expose one or more componentsExample:
exposes: { './ThisComponent': './src/components/ThisComponent', './ThatComponent': './src/components/ThisComponent', }
See https://github.com/module-federation/module-federation-examples as reference examples
ESLint has been set up with using the config from: @badboyku/eslint-config-badboyku
- To run eslint:
yarn lintornpm run lint - To run eslint with fix:
yarn lint:fixornpm run lint:fix
NOTE: You are able to override a rule by updating the rules inside the .eslintrc.js file.
Example:
rules: {
'no-console': 'error',
},
Prettier has been configured to help format css, scss, json files
- To run prettier:
yarn prettierornpm run prettier - To run prettier with fix:
yarn prettier:fixornpm run prettier:fix
Jest has been set up with coverage needing at least 80%. We are following industry standards to keep test files and snapshots in the src folder.
- To run jest:
yarn testornpm test - To run jest and update snapshots:
yarn test -uornpm test -u - To run jest test coverage:
yarn test:coverageornpm test:coverage - To run jest watch mode:
yarn test:watchornpm test:watch
In the src folder, let's try to keep a components, pages, and routes folder, in order to have a common folder structure for each MFE app. Apart from that, create folders to support your application.