hexo-browsersync icon indicating copy to clipboard operation
hexo-browsersync copied to clipboard

Not working

Open Monster0303 opened this issue 5 years ago • 6 comments

Hello I use the hexo3.9 mist theme I installed and started this way.

Npm install -g browser-sync
Npm install hexo-browsersync --save
Hexo server

But nothing happened What should I do?

Monster0303 avatar Jul 09 '19 16:07 Monster0303

same issue, Browsersync not working....

"hexo": "^3.9.0",
"hexo-browsersync": "^0.3.0"

85Ryan avatar Jul 15 '19 01:07 85Ryan

Try to reproduce Currently found:

  1. When the blog's home page is saved, saving the markdown file will be refreshed. This is useless because the home page can only be refreshed.
  2. (Occasionally) On the article page, after a few minutes, the real-time refresh function will work normally.

Can't find the law completely

Monster0303 avatar Jul 15 '19 05:07 Monster0303

Same issue here, not every time but the probability is high. When opening any other pages the browser shows Browsersync: connected, except the page not published yet.

"hexo": "^4.2.0",
"hexo-browsersync": "^0.3.0",

qianbinbin avatar Mar 25 '20 09:03 qianbinbin

I had the same issues, the state is. it's hard to tell why.

for me, i am expecting changes when editing some css or sass file, but it's not!!!

sukrosono avatar May 02 '21 10:05 sukrosono

I had switched to hugo, with this feature builtin.

qianbinbin avatar May 02 '21 11:05 qianbinbin

I investigated this issue.

hexo-browsersync is using connect-injector to insert a snippet into the response. In particular, it searches for

and inserts the code for reload just before it. However, the content of the converter function is missing the end. Therefore, the is not found and the code for Reload is not inserted.

About connect-injector. The write function receives the chunk and writes it to the WritableStreamBuffer of the node-stream-buffer. At this time, the chunk is complete HTML and there is no missing data. However, after the chunk is written to WritableStreamBuffer, it is missing. This seems to be a bug in node-stream-buffer.

The version of node-stream-buffer used by connect-injector is 0.2.3, which is very old. As a work-around, set it to 0.2.6 and it will work. If you increase the version too much, it will stop working.

node_modules/
  connect-injector/
    package.json
      : "stream-buffers": "^0.2.3" -> "stream-buffers": "^0.2.6"
$ npm install

after then,

node_modules/
  connect-injector/
    node_modules/
      stream-buffers # version 0.2.6

In the future, I think it would be better to use something else since connect-injector is an old library.

Another solution

Use the browse-sync proxy.

npm install -g browser-sync
browser-sync start --proxy localhost:4000 --files *

After then, access to http://localhost:3000/

tamtam180 avatar Jul 22 '21 16:07 tamtam180