Skip to content

Commit

Permalink
improve finding strategy for HtmlWebpackPlugin
Browse files Browse the repository at this point in the history
  • Loading branch information
hasanayan committed Jun 19, 2021
1 parent e20dd37 commit 80a5af7
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ module.exports = {
const fastRefreshEnabled = process.env.FAST_REFRESH !== "false";
const isEnvDevelopment = env === "development";

console.log(webpackConfig.plugins);
webpackConfig.output = {
...webpackConfig.output,
publicPath: "auto",
Expand All @@ -26,9 +27,12 @@ module.exports = {
isEnvDevelopment || namedModuleIdsOnProduction ? "named" : undefined,
};

webpackConfig.plugins[1].userOptions.hash = true;
const htmlWebpackPlugin = webpackConfig.plugins.find(
(plugin) => (plugin.constructor.name = "HtmlWebpackPlugin")
);
htmlWebpackPlugin.userOptions.hash = true;
if (fastRefreshEnabled && isEnvDevelopment) {
webpackConfig.plugins[1].userOptions.chunks = ["main"];
htmlWebpackPlugin.userOptions.chunks = ["main"];
}

return webpackConfig;
Expand Down

0 comments on commit 80a5af7

Please sign in to comment.