Reactjs 模块联合:webpack.config中可能存在带slug的远程url?
我希望使用模块联合在主机应用程序中使用来自远程应用程序的组件。是否可以动态更改webpack.config文件中的远程url,以包含运行时可能更改的段塞 网页包配置文件Reactjs 模块联合:webpack.config中可能存在带slug的远程url?,reactjs,webpack,webpack-module-federation,Reactjs,Webpack,Webpack Module Federation,我希望使用模块联合在主机应用程序中使用来自远程应用程序的组件。是否可以动态更改webpack.config文件中的远程url,以包含运行时可能更改的段塞 网页包配置文件 plugins: [ new ModuleFederationPlugin( { name: 'MFE2', filename: 'remoteEntry.js', remotes: { MFE1:
plugins: [
new ModuleFederationPlugin(
{
name: 'MFE2',
filename:
'remoteEntry.js',
remotes: {
MFE1:
'MFE1@http://localhost:8083/remoteEntry.js',
},
}
),
new HtmlWebpackPlugin({
template:
'./public/index.html',
}),
],
从上面的示例中,我想更改远程url以从localhost:8083/[slug]/remoteEntry.js提取组件
不确定模块联合是否支持包含基于url中的slug创建的组件
感谢您的帮助 简而言之,您目前无法做到这一点,因为webpack在构建时完成了它的工作,URL被烘焙到包中 有关此功能的详细信息 有一个空位 在运行时解析某种模板 变通办法 这里有一个使用高级api进行动态模块加载的官方示例,您完全避免在Web包配置中使用“remotes”,而是在代码中加载模块,并根据需要计算URL