Skip to content

Commit 1684a5a

Browse files
committed
bug #939 fixing 2 issues related to webpack-dev-server and HMR (weaverryan)
This PR was squashed before being merged into the main branch. Discussion ---------- fixing 2 issues related to webpack-dev-server and HMR Fixes #931 * `liveReload` currently causes the page to ALWAYS reload: HMR never has a chance to update the content. Disabling by default. This will mean people that currently like the liveReload won't have it anymore unless they re-enable it. But allowing HMR to be broken is not ok. See: #931 (comment) * The hostname used for the web socket changed in Webpack 4. For most users it doesn't matter... they use localhost everywhere. But this PR explicitly sets the web socket hostname to the hostname of the dev-server. TODO: fix/add tests Cheers! Commits ------- ed41a52 making test more fault tolerant 4178f64 fixing 2 issues related to webpack-dev-server and HMR - fixes #931
2 parents 4bb672a + ed41a52 commit 1684a5a

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

lib/config-generator.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -597,6 +597,16 @@ class ConfigGenerator {
597597
headers: { 'Access-Control-Allow-Origin': '*' },
598598
compress: true,
599599
historyApiFallback: true,
600+
// In webpack-dev-server v4 beta 0, liveReload always causes
601+
// the page to refresh, not allowing HMR to update the page.
602+
// This is somehow related to the "static" option, but it's
603+
// unknown if there is a better option.
604+
// See https://github.com/webpack/webpack-dev-server/issues/2893
605+
liveReload: false,
606+
client: {
607+
// see https://github.com/symfony/webpack-encore/issues/931#issuecomment-784483725
608+
host: this.webpackConfig.runtimeConfig.devServerHost,
609+
}
600610
};
601611

602612
return applyOptionsCallback(

test/functional.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2212,11 +2212,11 @@ module.exports = {
22122212
testSetup.runWebpack(config, (webpackAssert) => {
22132213
webpackAssert.assertDirectoryContents([
22142214
'entrypoints.json',
2215-
'runtime.fbc90386.js',
2216-
'main.06a6c20f.js',
2215+
'runtime.[hash:8].js',
2216+
'main.[hash:8].js',
22172217
'manifest.json',
2218-
'symfony_logo.91beba37.png',
2219-
'symfony_logo_alt.f880ba14.png',
2218+
'symfony_logo.[hash:8].png',
2219+
'symfony_logo_alt.[hash:8].png',
22202220
]);
22212221

22222222
webpackAssert.assertManifestPath(

0 commit comments

Comments
 (0)