const { ModuleFederationPlugin } = require("webpack").container;

module.exports = {
  devServer: {
    port: 3001,
    historyApiFallback: true,
  },
  webpack: {
    plugins: {
      add: [
        new ModuleFederationPlugin({
          name: 'kms',
          filename: 'remoteEntry.js',
          exposes: {
            './App': './src/federated/KMSApp',
            './SearchProvider': './src/federated/SearchProvider',
          },
          shared: {
            react: { 
              singleton: true,
              requiredVersion: '^19.1.1'
            },
            'react-dom': { 
              singleton: true,
              requiredVersion: '^19.1.1'
            },
            'react-router-dom': { 
              singleton: true,
              requiredVersion: '^7.8.2'
            },
            antd: { 
              singleton: true,
              requiredVersion: '^5.27.1'
            },
            axios: {
              singleton: true
            }
          },
        }),
      ],
    },
    configure: (webpackConfig) => ({
      ...webpackConfig,
      output: {
        ...webpackConfig.output,
        publicPath: "auto",
      },
    }),
  },
};