const HtmlWebPackPlugin = require("html-webpack-plugin"); const ModuleFederationPlugin = require("webpack/lib/container/ModuleFederationPlugin"); const path = require("path"); const deps = require("./package.json").dependencies; module.exports = { output: { publicPath: "http://localhost:5002", filename: "bundle.js", path: path.resolve(__dirname, "dist"), }, resolve: { extensions: [".jsx", ".js", ".json"], fallback: { crypto: false, }, }, devServer: { port: 5002, contentBase: path.join(__dirname, "public"), contentBasePublicPath: "/products/people/", }, module: { rules: [ { test: /\.m?js/, type: "javascript/auto", resolve: { fullySpecified: false, }, }, { test: /\.react.svg$/, use: ["@svgr/webpack"], }, { test: /\.json$/, loader: "json-loader" }, { test: /\.css$/i, use: ["style-loader", "css-loader"], }, { test: /\.s[ac]ss$/i, use: [ // Creates `style` nodes from JS strings "style-loader", // Translates CSS into CommonJS "css-loader", // Compiles Sass to CSS "sass-loader", ], }, { test: /\.(js|jsx)$/, exclude: /node_modules/, use: [ { loader: "babel-loader", options: { presets: ["@babel/preset-react", "@babel/preset-env"], plugins: [ "@babel/plugin-transform-runtime", "@babel/plugin-proposal-class-properties", "@babel/plugin-proposal-export-default-from", ], }, }, "source-map-loader", ], }, ], }, plugins: [ new ModuleFederationPlugin({ name: "people", filename: "remoteEntry.js", remotes: { studio: "studio@http://localhost:5001/remoteEntry.js", people: "people@http://localhost:5002/remoteEntry.js", }, exposes: { "./page": "./src/PeopleContent.jsx", }, shared: { ...deps, react: { singleton: true, requiredVersion: deps.react, }, "react-dom": { singleton: true, requiredVersion: deps["react-dom"], }, }, }), new HtmlWebPackPlugin({ template: "./public/index.html", }), ], };