我正在尝试更好地了解 Webpack 和 MFE。 构建了一个包含 2 个 React 模块的 React 容器。到目前为止效果很好。我还没有完成所有路由的实现,但每次我在 URL 中输入一些内容时:
http://localhost:4230/trainees/add
这是我的 MFE 配置:
new ModuleFederationPlugin( {
name : 'container',
remotes : {
trainer : 'trainer@http://localhost:4230/remoteEntry.js',
trainee : 'trainee@http://localhost:4220/remoteEntry.js'
},
shared: ['react', 'react-dom', {
'react-router-dom': {
singleton: true
}
}],
})
如果我尝试在代码中使用
<Nav>
访问相同的网址,它会起作用...
这是正常行为吗?
谢谢
找到了!
是webpack文件中的historyApiFallback。 我只是将其设置为 true:
historyApiFallback: {
index : true
},