|
| 1 | +const {ModuleFederationPlugin} = require('webpack').container; |
| 2 | +const path = require('path'); |
| 3 | + |
| 4 | +module.exports = { |
| 5 | + entry: './src/index', |
| 6 | + mode: 'development', |
| 7 | + devServer: { |
| 8 | + contentBase: path.join(__dirname, 'dist'), |
| 9 | + port: process.env.REACT_APP_FED_PORT, |
| 10 | + }, |
| 11 | + output: { |
| 12 | + publicPath: `http://localhost:${process.env.REACT_APP_FED_PORT}/`, |
| 13 | + }, |
| 14 | + module: { |
| 15 | + rules: [ |
| 16 | + { |
| 17 | + test: /\.jsx?$/, |
| 18 | + loader: 'babel-loader', |
| 19 | + exclude: /node_modules/, |
| 20 | + options: { |
| 21 | + presets: ['@babel/preset-react'], |
| 22 | + }, |
| 23 | + }, |
| 24 | + ], |
| 25 | + }, |
| 26 | + plugins: [ |
| 27 | + new ModuleFederationPlugin({ |
| 28 | + name: 'web_app_federation', |
| 29 | + library: {type: 'var', name: 'web_app_federation'}, |
| 30 | + filename: 'remoteEntry.js', |
| 31 | + exposes: { |
| 32 | + './App': './src/App', |
| 33 | + './index': './src/index', |
| 34 | + }, |
| 35 | + shared: { |
| 36 | + 'react-dom': 'react-dom', |
| 37 | + moment: '^2.24.0', |
| 38 | + react: { |
| 39 | + import: 'react', // the "react" package will be used a provided and fallback module |
| 40 | + shareKey: 'react', // under this name the shared module will be placed in the share scope |
| 41 | + shareScope: 'default', // share scope with this name will be used |
| 42 | + singleton: true, // only a single version of the shared module is allowed |
| 43 | + }, |
| 44 | + }, |
| 45 | + }), |
| 46 | + ], |
| 47 | +}; |
0 commit comments