You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Create a new Vue app using vue create, start it using yarn serve and open it in the browser.
What is expected?
webpack-dev-server/client is loaded once.
What is actually happening?
webpack-dev-server/client is loaded twice.
Details
As you can see in the screenshot below, sockjs-node/info is loaded twice, and there are two opened websocket connections, one from localhost and the other from the machine's IP 192.168.1.4:
Looking at the generated bundle app.js, we can see that webpack-dev-server/client is loaded twice:
One of the clients - the second, webpack-dev-server/client/index.js?http://192.168.1.4:8080/sockjs-node - is added by vue-cli-service's serve command here:
so the question is, where is the first one webpack-dev-server/client/index.js?http://localhost coming from? My first guess was that it was automatically added by webpack-dev-server; indeed, going through the docs, I found the injectClient configuration option that specifies whether the dev server should inject the client or not. The weird thing is that the docs say the default value is false?!, but let's see what happens if we explicitly set it to false. So I added this to vue.config.js
Version
4.1.1
Environment info
Steps to reproduce
Create a new Vue app using
vue create
, start it usingyarn serve
and open it in the browser.What is expected?
webpack-dev-server/client
is loaded once.What is actually happening?
webpack-dev-server/client
is loaded twice.Details
As you can see in the screenshot below,
sockjs-node/info
is loaded twice, and there are two opened websocket connections, one fromlocalhost
and the other from the machine's IP192.168.1.4
:Looking at the generated bundle
app.js
, we can see thatwebpack-dev-server/client
is loaded twice:Investigation
One of the clients - the second,
webpack-dev-server/client/index.js?http://192.168.1.4:8080/sockjs-node
- is added byvue-cli-service
'sserve
command here:vue-cli/packages/@vue/cli-service/lib/commands/serve.js
Line 145 in 02f2436
webpack-dev-server/client/index.js?http://localhost
coming from? My first guess was that it was automatically added bywebpack-dev-server
; indeed, going through the docs, I found theinjectClient
configuration option that specifies whether the dev server should inject the client or not. The weird thing is that the docs say the default value isfalse
?!, but let's see what happens if we explicitly set it tofalse
. So I added this tovue.config.js
restarted
yarn serve
, and, lo and behold, the client is now only loaded once!My guess is that if
hot
is set totrue
vue-cli/packages/@vue/cli-service/lib/commands/serve.js
Line 173 in 02f2436
injectClient
totrue
by default.Workaround
Set
devServer.injectClient
tofalse
invue.config.js
:Fix
(assuming this is considered a bug)
Explicitly set
injectClient
tofalse
in theWebpackDevServer
optionsvue-cli/packages/@vue/cli-service/lib/commands/serve.js
Lines 164 to 166 in 02f2436
The text was updated successfully, but these errors were encountered: