Closed
Description
HostApp webconfig setup
{
entry: './src/index',
mode: 'development',
devServer: {
contentBase: path.join(__dirname, 'dist'),
port: 3001
},
optimization: {
minimize: false,
runtimeChunk: true
},
output: {
publicPath: 'auto'
},
module: {
rules: [
{
test: /\.jsx?$/,
loader: 'babel-loader',
exclude: /node_modules/,
options: {
presets: ['@babel/preset-react']
}
}
]
},
plugins: [
new ModuleFederationPlugin({
name: 'app1',
remotes: {
app2: 'app2@[app1Url]/remoteEntry.js'
},
shared: { react: { singleton: true }, 'react-dom': { singleton: true } }
}),
new ExternalTemplateRemotesPlugin(),
new HtmlWebpackPlugin({
template: './public/index.html',
excludeChunks: ['app1']
})
]
}
RemoteApp webconfig setup
{
entry: './src/index',
mode: 'development',
devServer: {
contentBase: path.join(__dirname, 'dist'),
port: 3002
},
optimization: {
minimize: false,
runtimeChunk: true
},
output: {
publicPath: 'auto'
},
module: {
rules: [
{
test: /\.jsx?$/,
loader: 'babel-loader',
exclude: /node_modules/,
options: {
presets: ['@babel/preset-react']
}
}
]
},
plugins: [
// To learn more about the usage of this plugin, please visit https://webpack.js.org/plugins/module-federation-plugin/
new ModuleFederationPlugin({
name: 'app2',
library: { type: 'var', name: 'app2' },
filename: 'remoteEntry.js',
exposes: {
'./App': './src/App'
},
shared: { react: { singleton: true }, 'react-dom': { singleton: true } }
}),
new HtmlWebpackPlugin({
template: './public/index.html',
excludeChunks: ['app2']
})
]
};
in the remote app config if i am removing optimization option it is working fine but with optimization option it is giving me error like ScriptExternalLoadError: Loading script failed.