我开始尝试使用 webpack 模块联合的微前端。这是为了一个非常特殊的目的,因为在我们公司,我们开发大型软件,例如在基于角色的访问控制中做出反应的仪表板,我希望每个部分(或几乎)都是一个单独的应用程序。
所以我设法实现了一切,只是我注意到当我修改远程应用程序时,应用程序容器的自动重新加载没有完成。我可以理解为什么,但我想知道是否有办法修改它?知道我不能只在远程应用程序上工作,因为它使用应用程序容器的冗余提供程序......
这是我的应用程序容器的 webpack 配置:
const ReactRefreshPlugin = require("@pmmmwh/react-refresh-webpack-plugin");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const ModuleFederationPlugin = require("webpack").container
.ModuleFederationPlugin;
const path = require("path");
const deps = require("./package.json").dependencies;
module.exports = {
entry: "./src/index",
target:"web",
mode: "development",
devServer: {
contentBase: path.join(__dirname, "dist"),
port: 3001,
hot:true
},
output: {
publicPath: "auto",
},
resolve: {
extensions: [".js", ".jsx", ".json", ".ts", ".tsx"],
},
module: {
rules: [
{
test: /bootstrap\.tsx$/,
loader: "bundle-loader",
options: {
lazy: true,
},
},
{
test: /\.tsx?$/,
loader: "babel-loader",
exclude: …
Run Code Online (Sandbox Code Playgroud)