yuanqing / rdd

:pencil: Preview your Markdown locally as it would appear on GitHub, with live updating
MIT License
11 stars 3 forks source link

Live reload not working #2

Open rashil2000 opened 3 years ago

rashil2000 commented 3 years ago

The browser page does not refresh whenever I edit and save the file.

[OS: Windows 10]

yuanqing commented 3 years ago

Unfortunately I’m not able to reproduce this issue on OSX. (And also unable to debug because I don’t have a Windows PC.)

To be precise, the expected behavior is that when your Markdown file changes, the rendered page should update transparently without a refresh – note that this is different from how “Live Reload” works.

rashil2000 commented 3 years ago

Yes, even the transparent update doesn't work unfortunately.

Is there something I can help you debug it?

rashil2000 commented 3 years ago

Would you please point me towards the part of the code that does file-watching? I'll see if I can fix and send a PR. Thanks!

rashil2000 commented 3 years ago

I have located the issue: the address 0.0.0.0 does not work on Windows (or maybe it's not configured to route to localhost by default)

Changing it here: https://github.com/yuanqing/rdd/blob/f85dc5dba860f41cc29ee04399e551c529df1097/src/js/serve.js#L87 and here: https://github.com/yuanqing/rdd/blob/f85dc5dba860f41cc29ee04399e551c529df1097/src/js/client.js#L5 to 127.0.0.1 works!

Would you like me to send a PR?

yuanqing commented 3 years ago

Is there a way to make a change that would work for both MacOS and Windows?

rashil2000 commented 3 years ago

I believe the address 127.0.0.1 should work everywhere - Linux/Mac/Win.

Does it not work for you (I don't have a way to check on MacOS)?

yuanqing commented 3 years ago

@rashil2000 Are you able to verify if the fix in https://github.com/yuanqing/rdd/pull/3 fixes the issue on WIndows?

rashil2000 commented 3 years ago

Hi @yuanqing

Yes, the address change fixes the live-reloading issue.

However, there are multiple other quirks in rdd that prevent it from building under, and running properly on Windows.

  1. The build script uses cat command, which does not exist on Windows: https://github.com/yuanqing/rdd/blob/f85dc5dba860f41cc29ee04399e551c529df1097/package.json#L63
  2. The path resolution library globby, that is being used to resolve markdown files, does not work with Windows-style paths. https://github.com/yuanqing/rdd/blob/f85dc5dba860f41cc29ee04399e551c529df1097/src/js/resolve-markdown-files.js#L22

I have a fork of rdd, which is 2 commits ahead of upstream, and fixes these problems.