Skip to content

Commit 296dc83

Browse files
committed
fix: show warning when hot is enabled with HMR plugin in config
1 parent 8f20c3e commit 296dc83

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

lib/Server.js

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1056,16 +1056,20 @@ class Server {
10561056
// TODO remove after drop webpack v4 support
10571057
compiler.options.plugins = compiler.options.plugins || [];
10581058

1059-
if (
1060-
this.options.hot &&
1061-
!compiler.options.plugins.find(
1059+
if (this.options.hot) {
1060+
const HMRPluginExists = compiler.options.plugins.find(
10621061
(p) => p.constructor === webpack.HotModuleReplacementPlugin
1063-
)
1064-
) {
1065-
// apply the HMR plugin, if it didn't exist before.
1066-
const plugin = new webpack.HotModuleReplacementPlugin();
1062+
);
10671063

1068-
plugin.apply(compiler);
1064+
if (HMRPluginExists) {
1065+
this.logger.warn(
1066+
`"hot: true" automatically applies HMR plugin, you don't have to add it manually to your webpack configuration.`
1067+
);
1068+
} else {
1069+
// apply the HMR plugin
1070+
const plugin = new webpack.HotModuleReplacementPlugin();
1071+
plugin.apply(compiler);
1072+
}
10691073
}
10701074
});
10711075

0 commit comments

Comments
 (0)