ca-mfe-page-scoring-ui
Version:
This is a react shell for the SPGI Platform MFE implementation
132 lines (130 loc) • 3.69 kB
JavaScript
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const webpack = require('webpack');
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
const { ModuleFederationPlugin } = require('webpack').container;
const deps = require('./package.json').dependencies;
const TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin');
const isDevServer = process.env.WEBPACK_SERVE;
module.exports = {
entry: {
polyfills: './polyfills',
mfe_site: './src/index.tsx',
},
resolve: {
plugins: [
new TsconfigPathsPlugin(),
],
extensions: ['.tsx', '.js', '.ts'],
},
optimization: {
splitChunks: false
},
module: {
rules: [
{
test: /\.(js|ts)x?$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
},
},
{
test: /\.(scss|css)$/,
use: [
'@teamsupercell/typings-for-css-modules-loader',
'style-loader',
{
loader: 'css-loader',
options: { modules: true },
},
'sass-loader',
],
exclude: path.resolve(__dirname, './src/styles')
},
{
test: /\.(scss|css)$/,
use: ['style-loader', 'css-loader', 'sass-loader'],
include: path.resolve(__dirname, './src/styles'),
},
{
test: /\.(png|jpe?g|gif|woff(2)?|ttf|eot)$/i,
use: [{ loader: 'file-loader' }],
},
{
test: /\.(svg)$/i,
type: 'asset/inline',
},
{
test: /\.m?js/,
resolve: {
fullySpecified: false,
},
},
],
},
devServer: {
historyApiFallback: true,
compress: true,
headers: {
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Methods': 'GET, POST, PUT, DELETE, PATCH, OPTIONS',
'Access-Control-Allow-Headers': 'X-Requested-With, content-type, Authorization',
},
static: './dist',
port: 9192,
},
output: {
libraryTarget: 'umd',
path: path.resolve(__dirname, '../build/scoringui'),
},
plugins: [
new CleanWebpackPlugin(),
// new webpack.DefinePlugin({
// BASE_PATH: JSON.stringify(''),
// RG_WIDGET_UI_MFE_URL: JSON.stringify(isDevServer ? 'http://localhost:9193/remoteEntry.js' : '/rgWidget/remoteEntry.js'),
// }),
new ModuleFederationPlugin({
name: 'scoringui',
filename: 'remoteEntry.js',
exposes: {
'./suiIndex': './src/containers/ScoringUIContainer.tsx',
},
shared: [
{
react: {
singleton: true,
requiredVersion: deps['react']
},
'react-dom': {
singleton: true,
requiredVersion: deps['react-dom']
},
'react-router-dom': {
singleton: true,
requiredVersion: deps['react-router-dom']
},
'react-redux': {
singleton: true,
requiredVersion: deps['react-redux']
},
'@spglobal/ca-mfe-package-utils': {
singleton: true,
requiredVersion: deps['@spglobal/ca-mfe-package-utils']
},
i18next: {
singleton: true,
requiredVersion: deps.i18next,
}
},
]
}),
new HtmlWebpackPlugin({
inject: true, // Inject all files that are generated by webpack, e.g. bundle.js
template: 'public/index.html',
}),
new webpack.ProvidePlugin({
process: 'process/browser',
}),
],
};