-
Notifications
You must be signed in to change notification settings - Fork 15
/
webpack.config.js
50 lines (49 loc) · 1.65 KB
/
webpack.config.js
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
const {ModuleFederationPlugin} = require('webpack').container;
const path = require('path');
module.exports = {
entry: './src/index',
mode: process.env.NODE_ENV || 'development',
devServer: {
contentBase: path.join(__dirname, 'dist'),
port: process.env.REACT_APP_FED_PORT,
},
output: {
publicPath:
process.env.NODE_ENV === 'production'
? '/demo/fed/dist/'
: `http://localhost:${process.env.REACT_APP_FED_PORT}/`,
},
module: {
rules: [
{
test: /\.jsx?$/,
loader: 'babel-loader',
exclude: /node_modules/,
options: {
presets: ['@babel/preset-react'],
},
},
],
},
plugins: [
new ModuleFederationPlugin({
name: 'web_app_federation',
library: {type: 'var', name: 'web_app_federation'},
filename: 'remoteEntry.js',
exposes: {
'./App': './src/App',
'./index': './src/index',
},
shared: {
'react-dom': 'react-dom',
moment: '^2.24.0',
react: {
import: 'react', // the "react" package will be used a provided and fallback module
shareKey: 'react', // under this name the shared module will be placed in the share scope
shareScope: 'default', // share scope with this name will be used
singleton: true, // only a single version of the shared module is allowed
},
},
}),
],
};