Skip to content

Commit

Permalink
fix: show warning when hot is enabled with HMR plugin in config
Browse files Browse the repository at this point in the history
  • Loading branch information
snitin315 committed Aug 25, 2021
1 parent 13cd267 commit 04f3914
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions lib/Server.js
Original file line number Diff line number Diff line change
Expand Up @@ -1044,16 +1044,20 @@ class Server {
// TODO remove after drop webpack v4 support
compiler.options.plugins = compiler.options.plugins || [];

if (
this.options.hot &&
!compiler.options.plugins.find(
if (this.options.hot) {
const HMRPluginExists = compiler.options.plugins.find(
(p) => p.constructor === webpack.HotModuleReplacementPlugin
)
) {
// apply the HMR plugin, if it didn't exist before.
const plugin = new webpack.HotModuleReplacementPlugin();
);

plugin.apply(compiler);
if (HMRPluginExists) {
this.logger.warn(
`"hot: true" automatically applies HMR plugin, you don't have to add it manually to your webpack configuration.`
);
} else {
// apply the HMR plugin
const plugin = new webpack.HotModuleReplacementPlugin();
plugin.apply(compiler);
}
}
});

Expand Down

0 comments on commit 04f3914

Please sign in to comment.