/simple-micro-frontend

This project is an example of micro frontend using Module Federation

Primary LanguageJavaScriptMIT LicenseMIT

Simple Micro Frontend

This project is an example of a micro frontend using Module Feredation

pt-br

πŸ’ͺ Motivation

More and more front-end projects get bigger and complex, in 2016 I had a really cool experience with micro frontends, at that time it was not very common and our approach can be said that it was not the best possible but it worked very well. This project intend to be a simple and scalable boilerplate of a micro frontend, in it I used the Module Federation, to better understand I recommend accessing the following links:

What's?

Webpack 5 Module Federation - Zack Jackson

🧩 Installation

After cloning the repository, you must run the command below at the root of the project:

yarn install-all

You need Node.js e Yarn

πŸƒβ€β™‚οΈRunning

Run the command below to start the applications: dashboard, profile and projects

yarn start-all

or if you prefer you can run the command below for each project: dashboard, profile and projects

yarn start

The ports of each project:

Project Port
dashboard 3000
profile 3001
projects 3002

πŸ— Project structure

The project structure presented is just an example, here I tried to make it as simple and scalable as possible:

.
β”œβ”€β”€ dashboard                # Full dashboard using the `profile` and` projects` page.
β”œβ”€β”€ profile                  # Profile containing only the profile page and related components.
β”œβ”€β”€ projects                 # Projects containing only the projects page and related components.

Internal structure of each project:

.
β”œβ”€β”€ public                   # Public files
β”œβ”€β”€ src                      # Application code source
β”‚ β”œβ”€β”€ components             # Generic application components
β”‚ β”œβ”€β”€ styles                 # Generic application styles
β”‚ β”œβ”€β”€ views                  # Pages used on the router
β”‚ β”œβ”€β”€ App.js                 # Main application bootstrap with routes
β”‚ β”œβ”€β”€ bootstrap.js           # Responsible for importing App.js and rendering in the DOM
β”‚ β”œβ”€β”€ index.js               # Performs async import from bootstrap.js
└── webpack.config.js        # Bundler the all project and also where modules are exported so that projects can be reused

✏️ License

This project is distributed under the MIT license.