forked from mercedes-benz/DnA
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
dataentry-mfe initial setup (mercedes-benz#2713)
- Loading branch information
1 parent
e5e5137
commit a26012c
Showing
109 changed files
with
18,503 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
CONTAINER_APP_URL=${PROJECTSMO_CONTAINER_APP_URL} | ||
API_BASEURL=${PROJECTSMO_API_BASEURL} | ||
DATA_ENTRY_API_BASEURL=${PROJECTSMO_DATA_ENTRY_API_BASEURL} | ||
REPORTS_API_BASEURL=${PROJECTSMO_REPORTS_API_BASEURL} | ||
STORAGE_API_BASEURL=${PROJECTSMO_STORAGE_API_BASEURL} | ||
TOU_HTML=${PROJECTSMO_TOU_HTML} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
CONTAINER_APP_URL= http://localhost:9090 | ||
API_BASEURL= | ||
DATA_ENTRY_API_BASEURL= | ||
REPORTS_API_BASEURL= | ||
STORAGE_API_BASEURL= | ||
TOU_HTML= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: 'data_entry_mfe', | ||
filename: 'remoteEntry.js', | ||
exposes: { | ||
'./DataEntry': './src/App', | ||
}, | ||
remotes: { | ||
'dna-container': `dna_container@[(window.DATA_ENTRY_INJECTED_ENVIRONMENT && window.DATA_ENTRY_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' }] }), | ||
], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: 8092, | ||
container: 'data-entry-mfe', | ||
standalone: false, | ||
}), | ||
], | ||
}; | ||
|
||
module.exports = merge(base, devConfig); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
const webpack = require('webpack'); | ||
const packageJson = require('../package.json'); | ||
const miniCssExtractPlugin = require('mini-css-extract-plugin'); | ||
const path = require('path'); | ||
const packageName = packageJson.name.replace(/@/, '-').replace(/\//, '-'); | ||
const version = packageJson.version.toLowerCase().trim(); | ||
const ESLintPlugin = require('eslint-webpack-plugin'); | ||
const optimizeCSSAssetsPlugin = require('css-minimizer-webpack-plugin'); | ||
const { CleanWebpackPlugin } = require('clean-webpack-plugin'); | ||
const terserPlugin = require('terser-webpack-plugin'); | ||
const duplicatePackageCheckerPlugin = require('duplicate-package-checker-webpack-plugin'); | ||
const base = require('./base.config'); | ||
const { merge } = require('webpack-merge'); | ||
|
||
const prodConfig = { | ||
mode: 'production', | ||
target: 'web', | ||
entry: './src/index.js', | ||
output: { | ||
path: path.resolve(__dirname, '../dist'), | ||
filename: `${packageName}_${version}_[name].[fullhash].js`, | ||
chunkFilename: `${packageName}_${version}_[name].[fullhash].bundle.js`, | ||
clean: true, | ||
publicPath: 'auto', | ||
}, | ||
devtool: false, | ||
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 CleanWebpackPlugin(), | ||
new webpack.ids.HashedModuleIdsPlugin(), | ||
new duplicatePackageCheckerPlugin(), | ||
new ESLintPlugin({ | ||
extensions: ['js'], | ||
fix: true, | ||
}), | ||
new miniCssExtractPlugin({ | ||
filename: `${packageName}_${version}_[name].[fullhash].css`, | ||
chunkFilename: `${packageName}_${version}_[name].[fullhash].bundle.css`, | ||
}), | ||
], | ||
optimization: { | ||
minimizer: [ | ||
new terserPlugin({ | ||
extractComments: true, | ||
parallel: true, | ||
terserOptions: { | ||
safari10: true, | ||
}, | ||
}), | ||
new optimizeCSSAssetsPlugin({}), | ||
], | ||
splitChunks: { | ||
chunks: 'async', | ||
}, | ||
}, | ||
}; | ||
|
||
module.exports = merge(base, prodConfig); |
Oops, something went wrong.