hexo-browsersync
hexo-browsersync copied to clipboard
Not working
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?
same issue, Browsersync not working....
"hexo": "^3.9.0",
"hexo-browsersync": "^0.3.0"
Try to reproduce Currently found:
- 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.
- (Occasionally) On the article page, after a few minutes, the real-time refresh function will work normally.
Can't find the law completely
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",
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!!!
I had switched to hugo, with this feature builtin.
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/