Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

3.0.0-beta.16 热更新失效 #1559

Closed
bigbanana opened this issue Jun 13, 2018 · 17 comments
Closed

3.0.0-beta.16 热更新失效 #1559

bigbanana opened this issue Jun 13, 2018 · 17 comments
Labels
needs reproduction This issue is missing a minimal runnable reproduction, provided by the author

Comments

@bigbanana
Copy link

Version

3.0.0-beta.15

Reproduction link

https://github.com/vuejs/vue-cli

Steps to reproduce

vue create test
cd test
rm -rf node_modules
npm install
npm run serve

What is expected?

HMR热更新失效

What is actually happening?

HMR socket连接没有问题,但是webpackHotUpdate事件无法触发,导致热更新失效,检查app.js发现 webpack/hot/emitter.js被webpack打包了两个,出现两个不同实例。


大致确定目标是@vue/cli-service@3.0.0-beta.16导致的,回退版本beta.10后暂时解决。由于时间急,没有继续追踪。

@bigbanana
Copy link
Author

抱歉,Version 写错了,是3.0.0-beta.16,模板不能选择beta.16,忘记更正了。

@jkzing
Copy link
Member

jkzing commented Jun 13, 2018

Can you paste your vue.config.js here ?

@bigbanana
Copy link
Author

const fs = require('fs')

module.exports = {
configureWebpack: {
disableHostCheck: true,
proxy: {
'/api': {
target: 'http://localhost:3000',
pathRewrite: {'^/api' : ''}
}
}
},
css: {
loaderOptions: {
sass: {
data: @import "@/variables.scss";
}
}
}
}

@yyx990803 yyx990803 added the needs reproduction This issue is missing a minimal runnable reproduction, provided by the author label Jun 13, 2018
@yyx990803
Copy link
Member

Need a valid repro.

你项目里是不是存在两个版本的 webpack?

@bigbanana
Copy link
Author

我检查过的,没有哦,如果你们无法重现问题,那我明天再仔细分析一下再回复。

@liukuo625341
Copy link

我也遇到了这个问题 ,项目刚创建完毕,什么都没有设置,控制台会提示 [WDS] Disconnected!,我把版本改成beta.15就可以正常热更新了

@SunshowerC
Copy link

same here

@immissile
Copy link

same issue.
@vue/cli-service@3.0.0-beta.15 worked well.

@LinusBorg
Copy link
Member

No reproduction provided after 19 days.

Closing until reproduction is provided.

@bigbanana
Copy link
Author

抱歉,好久没关注这个问题,今天仔细分析了一下,是因为使用了cnpm,cnpm使用symlink,导致webpack打包的时候抒符号链接的包打包了两份,由于webpack/hot/emitter.js为两个不同实例,导致webpack hot/server webpackHotUpdate无法触发,热更新失效。
解决方法:设置registry ,不使用cnpm.
npm config set registry https://registry.npm.taobao.org
npm install

@paraself
Copy link

Same issue, but is solved with your solution. Thanks!

@psaren
Copy link

psaren commented Aug 15, 2018

@bigbanana 谢谢!
遇到同样的问题,这个解决方法work了

@excaliburhan
Copy link

There is a resolve.symlinks in webpack configuration, and it's default value is true.
Howerver, project created by vue-cli, the resolve.symlinks is set to false.
For some reason, I have to use npm with symlink, the solution is set resolve.symlinks in vue.config.js
Like this:

module.exports = {
  chainWebpack: config => {
    config.resolve
        .symlinks(true)
    return config
  }
}

haoqunjiang added a commit to haoqunjiang/vue-cli that referenced this issue Aug 31, 2018
Currently in Vue CLI we set the default `symlinks` config to `false`.
This setting is counterintuitive, and inconsitent with webpack's default
configuration, per https://webpack.js.org/configuration/resolve/#resolve-symlinks

The change of default `symlinks` value is introduced by vuejs@5b4df14
It is most likely a duplicate of vuejs@145492b

Since several third-party npm clients uses symlinks to speed up installation
(e.g. cnpm, pnpm...), that change breaks webpack HMR for their users.
See vuejs#1559, vuejs#2195, vuejs#2284

This commit also fixes vuejs#1609
haoqunjiang added a commit to haoqunjiang/vue-cli that referenced this issue Aug 31, 2018
Currently in Vue CLI we set the default `symlinks` config to `false`.
This setting is counterintuitive, and inconsitent with webpack's default
configuration, per https://webpack.js.org/configuration/resolve/#resolve-symlinks

The change of default `symlinks` value is introduced by vuejs@5b4df14
It is most likely a duplicate of vuejs@145492b

Since several third-party npm clients uses symlinks to speed up installation
(e.g. cnpm, pnpm...), that change breaks webpack HMR for their users.
See vuejs#1559, vuejs#2195, vuejs#2284

This commit also fixes vuejs#1609
haoqunjiang added a commit to haoqunjiang/vue-cli that referenced this issue Sep 3, 2018
Currently in Vue CLI we set the default `symlinks` config to `false`.
This setting is counterintuitive, and inconsitent with webpack's default
configuration, per https://webpack.js.org/configuration/resolve/#resolve-symlinks

The change of default `symlinks` value is introduced by vuejs@5b4df14
It is most likely a duplicate of vuejs@145492b

Since several third-party npm clients uses symlinks to speed up installation
(e.g. cnpm, pnpm...), that change breaks webpack HMR for their users.
See vuejs#1559, vuejs#2195, vuejs#2284

This commit also fixes vuejs#1609
haoqunjiang added a commit to haoqunjiang/vue-cli that referenced this issue Sep 4, 2018
Currently in Vue CLI we set the default `symlinks` config to `false`.
This setting is counterintuitive, and inconsitent with webpack's default
configuration, per https://webpack.js.org/configuration/resolve/#resolve-symlinks

The change of default `symlinks` value is introduced by vuejs@5b4df14
It is most likely a duplicate of vuejs@145492b

Since several third-party npm clients uses symlinks to speed up installation
(e.g. cnpm, pnpm...), that change breaks webpack HMR for their users.
See vuejs#1559, vuejs#2195, vuejs#2284

This commit also fixes vuejs#1609
haoqunjiang added a commit that referenced this issue Sep 5, 2018
Currently in Vue CLI we set the default `symlinks` config to `false`.
This setting is counterintuitive, and inconsistent with webpack's default
configuration, per https://webpack.js.org/configuration/resolve/#resolve-symlinks

The change of default `symlinks` value is introduced by 5b4df14
It is most likely a duplicate of 145492b

Since several third-party npm clients uses symlinks to speed up installation
(e.g. cnpm, pnpm...), that change breaks webpack HMR for their users.
See #1559, #2195, #2284

This commit also fixes #1609
@ellakan
Copy link

ellakan commented Sep 12, 2018

devServer: {
useLocalIp: false,
proxy: 'http://localhost:8080',
public: '192.168.56.2:8080',
}
我加了public的设置,热更新管用的

@ruiyongsheng
Copy link

ruiyongsheng commented Sep 17, 2018

热更新HTML和JS能正常生效,但是css,改动了之后,并没生效,必须手动刷新浏览器才行,这个求解?

@z1shiki
Copy link

z1shiki commented Sep 22, 2018

@ruiyongsheng
可能在vue.config.js中配置了
css:{ extract: true, //需要热更新此处设置成false }

@jackchoumine
Copy link

jackchoumine commented Jan 15, 2022

"serve": "vue-cli-service serve --host localhost" in packge.json fix it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs reproduction This issue is missing a minimal runnable reproduction, provided by the author
Projects
None yet
Development

No branches or pull requests