-
Notifications
You must be signed in to change notification settings - Fork 44
Expand file tree
/
Copy pathwebpack.config.js
More file actions
57 lines (55 loc) · 1.48 KB
/
webpack.config.js
File metadata and controls
57 lines (55 loc) · 1.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const ReactRefreshPlugin = require('@pmmmwh/react-refresh-webpack-plugin');
const webpack = require('webpack');
const isProduction = process.env.NODE_ENV === 'production';
const containerName = 'Webpack_MF';
/** @type {import('webpack').Configuration} */
module.exports = {
entry: './src/index.js',
context: __dirname,
devtool: false,
output: {
uniqueName: containerName,
},
module: {
rules: [
{
test: /\.js$/,
include: path.resolve(__dirname, 'src'),
use: {
loader: 'babel-loader',
options: {
presets: [['@babel/preset-react', { runtime: 'automatic' }]],
plugins: [!isProduction && require.resolve('react-refresh/babel')].filter(Boolean),
},
},
},
],
},
plugins: [
new HtmlWebpackPlugin({ excludeChunks: [containerName] }),
new webpack.container.ModuleFederationPlugin({
name: containerName,
remotes: {
Rspack_MF_v1: 'Rspack_MF_v1@http://localhost:8080/Rspack_MF_v1.js',
Rspack_MF_v1_5: 'Rspack_MF_v1_5@http://localhost:8081/Rspack_MF_v1_5.js',
},
exposes: {
'./Component': './src/Component',
},
shared: {
react: {
singleton: true,
},
},
}),
!isProduction && new ReactRefreshPlugin(),
],
devServer: {
port: 8082,
headers: {
'Access-Control-Allow-Origin': '*',
},
},
};