Skip to content

Commit

Permalink
fabric mfe implementation (mercedes-benz#2683)
Browse files Browse the repository at this point in the history
* fabric mfe implementation

* added fabric to title
  • Loading branch information
aniruddha-k authored Mar 27, 2024
1 parent f106846 commit 9f5bcfe
Show file tree
Hide file tree
Showing 123 changed files with 21,325 additions and 4 deletions.
10 changes: 6 additions & 4 deletions deployment/kubernetes/helm/charts/fabric-mfe/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@
namespace: fabric
configJs: |
window["fabric_INJECTED_ENVIRONMENT"]={
ENABLE_fabric_SERVICE=true,
fabric_MFE_APP_URL="http://localhost:8089",
fabric_API_BASEURL="http://localhost:8989/api"
fabric_APP_URL='YOUR_fabric_APP_URL'
CONTAINER_APP_URL: "http://localhost:9090",
API_BASEURL: "http://localhost:7171/api",
FABRIC_API_BASEURL: 'YOUR_FABRIC_API_BASEURL',
REPORTS_API_BASEURL: 'YOUR_REPORTS_API_BASEURL',
STORAGE_API_BASEURL: 'YOUR_STORAGE_API_BASEURL',
TOU_HTML: "<div>I agree to <a href=\"#\" target=\"_blank\" rel=\"noopener noreferrer\">terms of use</a></div>",
};
replicaCount: 1
Expand Down
12 changes: 12 additions & 0 deletions deployment/kubernetes/helm/charts/frontend/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,13 @@ configJs: |
CODESPACE_OIDC_POPUP_WAIT_TIME: "5000",
ENABLE_CHRONOS_FORECASTING_SERVICE: "false",
ENABLE_DATALAKE_SERVICE: "false",
ENABLE_FABRIC_SERVICE: "false",
CHRONOS_MFE_APP_URL:"http://localhost:8085",
ENABLE_MATOMO_SERVICE:"true",
MATOMO_MFE_APP_URL:"http://localhost:8089",
MATOMO_APP_URL:"YOUR_MATOMO_APP_URL",
DATALAKE_MFE_APP_URL: 'http://localhost:8090',
FABRIC_MFE_APP_URL: 'http://localhost:8091',
UDEMY_URL= "YOUR_UDEMY_URL",
LINKEDIN_LEARNING_URL= "YOUR_LINKEDIN_LEARNING_URL",
Expand Down Expand Up @@ -161,6 +164,15 @@ configJs: |
API_BASEURL: "http://localhost:7171/api",
};
window["FABRIC_INJECTED_ENVIRONMENT"]={
CONTAINER_APP_URL:'http://localhost:9090',
API_BASEURL: 'http://localhost:7171/api',
FABRIC_API_BASEURL: 'YOUR_FABRIC_API_BASEURL',
STORAGE_API_BASEURL: 'http://localhost:7175/api',
REPORTS_API_BASEURL: 'http://localhost:7173/api',
TOU_HTML: "<div>I agree to <a href=\"#\" target=\"_blank\" rel=\"noopener noreferrer\">terms of use</a></div>",
};
probes:
Expand Down
6 changes: 6 additions & 0 deletions packages/fabric-mfe/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
CONTAINER_APP_URL= http://localhost:9090
API_BASEURL=
FABRIC_API_BASEURL=
REPORTS_API_BASEURL=
STORAGE_API_BASEURL=
TOU_HTML=
23 changes: 23 additions & 0 deletions packages/fabric-mfe/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.js

# testing
/coverage

# production
/build

# misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local

npm-debug.log*
yarn-debug.log*
yarn-error.log*
70 changes: 70 additions & 0 deletions packages/fabric-mfe/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# Getting Started with Create React App

This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).

## Available Scripts

In the project directory, you can run:

### `npm start`

Runs the app in the development mode.\
Open [http://localhost:3000](http://localhost:3000) to view it in your browser.

The page will reload when you make changes.\
You may also see any lint errors in the console.

### `npm test`

Launches the test runner in the interactive watch mode.\
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.

### `npm run build`

Builds the app for production to the `build` folder.\
It correctly bundles React in production mode and optimizes the build for the best performance.

The build is minified and the filenames include the hashes.\
Your app is ready to be deployed!

See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.

### `npm run eject`

**Note: this is a one-way operation. Once you `eject`, you can't go back!**

If you aren't satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.

Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you're on your own.

You don't have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn't feel obligated to use this feature. However we understand that this tool wouldn't be useful if you couldn't customize it when you are ready for it.

## Learn More

You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).

To learn React, check out the [React documentation](https://reactjs.org/).

### Code Splitting

This section has moved here: [https://facebook.github.io/create-react-app/docs/code-splitting](https://facebook.github.io/create-react-app/docs/code-splitting)

### Analyzing the Bundle Size

This section has moved here: [https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size](https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size)

### Making a Progressive Web App

This section has moved here: [https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app](https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app)

### Advanced Configuration

This section has moved here: [https://facebook.github.io/create-react-app/docs/advanced-configuration](https://facebook.github.io/create-react-app/docs/advanced-configuration)

### Deployment

This section has moved here: [https://facebook.github.io/create-react-app/docs/deployment](https://facebook.github.io/create-react-app/docs/deployment)

### `npm run build` fails to minify

This section has moved here: [https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify](https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify)
151 changes: 151 additions & 0 deletions packages/fabric-mfe/config/base.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
const HtmlWebpackPlugin = require('html-webpack-plugin');
const ModuleFederationPlugin = require('webpack/lib/container/ModuleFederationPlugin');
const deps = require('../package.json').dependencies;
const Dotenv = require('dotenv-webpack');
const path = require('path');
const ESLintPlugin = require('eslint-webpack-plugin');
const webpack = require('webpack');
const ExternalTemplateRemotesPlugin = require('external-remotes-plugin');
const copyWebpackPlugin = require('copy-webpack-plugin');

module.exports = {
module: {
rules: [
{
test: /\.(eot|woff2|woff|svg|otf)/,
dependency: { not: ['url'] },
use: [
{
loader: 'url-loader',
options: {
limit: 1000,
name: 'fonts/[name]-[contenthash].[ext]',
},
},
],
},
{
test: /\.(ttf)/,
dependency: { not: ['url'] },
use: [
{
loader: 'url-loader',
options: {
limit: 1000,
name: 'fonts/[name].[ext]',
},
},
],
},
{
test: /\.(png|jpg|gif)$/i,
type: 'asset/resource',
},
{
test: /\.(css|scss)$/,
use: [
{
loader: 'style-loader',
},
{
loader: 'css-loader',
options: {
sourceMap: true,
importLoaders: 1,
modules: {
auto: (resourcePath) => !resourcePath.includes('uilab'),
localIdentName: '[name]_[local]_[hash:base64:5]',
},
},
},
{
loader: 'postcss-loader',
options: {
sourceMap: true,
},
},
{
loader: 'sass-loader',
options: {
sourceMap: true,
},
},
],
include: [path.resolve(__dirname, path.join('..', 'src'))],
},
{
test: /\.(css|scss)$/,
use: [
{
loader: 'style-loader',
},
{
loader: 'css-loader',
},
],
exclude: [path.resolve(__dirname, path.join('..', 'src'))],
},
{
test: /config.js/,
use: [
{
loader: 'raw-loader',
},
],
include: [path.resolve(__dirname, path.join('..', 'public'))],
},
{
test: /\.m?js/,
resolve: {
fullySpecified: false,
},
},
],
},
plugins: [
new Dotenv({
path: process.env.NODE_ENV === 'development' ? '../.env' : '../.docker.env',
}),
new ESLintPlugin({
extensions: ['js'],
fix: true,
}),
//async await support in es6
new webpack.ProvidePlugin({
regeneratorRuntime: 'regenerator-runtime/runtime',
Promise: ['es6-promise', 'Promise'],
process: 'process/browser',
Buffer: ['buffer', 'Buffer'],
}),
new HtmlWebpackPlugin({
template: './public/index.html',
favicon: './src/appIcon/logo.png',
}),
new ExternalTemplateRemotesPlugin(),
new ModuleFederationPlugin({
name: 'fabric_mfe',
filename: 'remoteEntry.js',
exposes: {
'./Fabric': './src/App',
},
remotes: {
'dna-container': `dna_container@[(window.FABRIC_INJECTED_ENVIRONMENT && window.FABRIC_INJECTED_ENVIRONMENT.CONTAINER_APP_URL)]/remoteEntry.js?[(new Date()).getTime()]`,
},
shared: {
...deps,
react: { singleton: true, eager: true, requiredVersion: deps.react },
'react-dom': {
singleton: true,
eager: true,
requiredVersion: deps['react-dom'],
},
'react-router-dom': {
singleton: true,
eager: true,
requiredVersion: deps['react-router-dom'],
},
},
}),
new copyWebpackPlugin({ patterns: [{ from: 'public/config.js', toType: 'dir' }] }),
],
};
37 changes: 37 additions & 0 deletions packages/fabric-mfe/config/webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
const { MFLiveReloadPlugin } = require('@module-federation/fmr');
const base = require('./base.config');
const { merge } = require('webpack-merge');

const devConfig = {
mode: 'development',
devtool: 'inline-source-map',
devServer: {
port: 8091,
historyApiFallback: true,
headers: {
'Access-Control-Allow-Origin': '*',
},
},
module: {
rules: [
{
test: /\.js?$/,
exclude: /node_modules/,
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env' /* to transfer any advansed ES to ES5 */, '@babel/preset-react'], // to compile react to ES5
plugins: [['@babel/plugin-transform-runtime']],
},
},
],
},
plugins: [
new MFLiveReloadPlugin({
port: 8091,
container: 'fabric-mfe',
standalone: false,
}),
],
};

module.exports = merge(base, devConfig);
Loading

0 comments on commit 9f5bcfe

Please sign in to comment.