Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…deration into main
  • Loading branch information
hasanayan committed Jun 18, 2021
2 parents be0cf5d + 8afba50 commit a4d6f4b
Show file tree
Hide file tree
Showing 50 changed files with 31,916 additions and 0 deletions.
63 changes: 63 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
const webpack = require("webpack");
const ModuleFederationPlugin = webpack.container.ModuleFederationPlugin;
const ExternalTemplateRemotesPlugin = require("external-remotes-plugin");

module.exports = {
overrideWebpackConfig: ({
webpackConfig,
context: { env },
pluginOptions: {
namedModuleIdsOnProduction = false,
namedChunkIdsOnProduction = false,
},
}) => {
const fastRefreshEnabled = process.env.FAST_REFRESH !== "false";
const isEnvDevelopment = env === "development";

webpackConfig.output = {
...webpackConfig.output,
publicPath: "auto",
};

webpackConfig.optimization = {
chunkIds:
isEnvDevelopment || namedChunkIdsOnProduction ? "named" : undefined,
moduleIds:
isEnvDevelopment || namedModuleIdsOnProduction ? "named" : undefined,
};

webpackConfig.plugins[1].userOptions.hash = true;
if (fastRefreshEnabled && isEnvDevelopment) {
webpackConfig.plugins[1].userOptions.chunks = ["main"];
}

return webpackConfig;
},

overrideCracoConfig: ({
cracoConfig,
pluginOptions: {
federationConfig,
useExternalRemotesPlugin = false,
removeWatchMissingNodeModulesPlugin = true,
},
}) => {
if (!cracoConfig.webpack) cracoConfig.webpack = {};
if (!cracoConfig.webpack.plugins) cracoConfig.webpack.plugins = {};

cracoConfig.webpack.plugins.add = [
...(cracoConfig.webpack.plugins.add || []),
new ModuleFederationPlugin(federationConfig),
useExternalRemotesPlugin && new ExternalTemplateRemotesPlugin(),
].filter(Boolean);

cracoConfig.webpack.plugins.remove = ["WebpackManifestPlugin"];

cracoConfig.webpack.plugins.remove = [
...cracoConfig.webpack.plugins.remove,
removeWatchMissingNodeModulesPlugin && "WatchMissingNodeModulesPlugin",
].filter(Boolean);

return cracoConfig;
},
};
Loading

0 comments on commit a4d6f4b

Please sign in to comment.