This project demonstrates a microfrontend architecture using a main app and dynamically loaded plugins.
main-app/
: The core application that loads and manages pluginsplugin-a/
: An example pluginconfig-server/
: A simple server to provide plugin configurations
-
Navigate to the
main-app
directory:cd main-app
-
Install dependencies:
npm install
-
Start the development server:
npm run dev
The main app will be available at http://localhost:3000
.
-
Navigate to the
plugin-a
directory:cd plugin-a
-
Install dependencies:
npm install
-
Build the plugin:
npm run build
-
Serve the built plugin:
npm run serve
The plugin will be served at http://localhost:5000/plugin-a.js
.
-
Navigate to the
config-server
directory:cd config-server
-
Install dependencies:
npm install
-
Start the server:
npm start
The config server will run on http://localhost:3001
.
To add a new plugin:
- Create a new directory for your plugin (e.g.,
plugin-b
) - Implement the plugin following the structure of
plugin-a
- Update the config server to include the new plugin's configuration
- Build and serve the new plugin
- Restart the main app to load the new plugin
- Dynamic loading of plugins
- React-based main app and plugins
- TypeScript support
- Vite for fast development and building
- Ensure all servers (main app, plugins, and config server) are running for the full functionality
- The main app fetches plugin configurations from the config server on startup
- Plugins are loaded dynamically based on the configurations