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

Live reload not working #2

Open
rashil2000 opened this issue Jul 25, 2021 · 8 comments
Open

Live reload not working #2

rashil2000 opened this issue Jul 25, 2021 · 8 comments

Comments

@rashil2000
Copy link

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

[OS: Windows 10]

@yuanqing
Copy link
Owner

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
Copy link
Author

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

Is there something I can help you debug it?

@rashil2000
Copy link
Author

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
Copy link
Author

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:

const url = `0.0.0.0:${serverPort}/${file}`

and here:
`ws://0.0.0.0:${window.__rddWebSocketPort}/`

to 127.0.0.1 works!

Would you like me to send a PR?

@yuanqing
Copy link
Owner

yuanqing commented Aug 6, 2021

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

@rashil2000
Copy link
Author

rashil2000 commented Aug 6, 2021

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
Copy link
Owner

@rashil2000 Are you able to verify if the fix in #3 fixes the issue on WIndows?

@rashil2000
Copy link
Author

rashil2000 commented Aug 15, 2021

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:
    "build-css-light": "mkdirp build/css && cat src/css/style.css node_modules/highlight.js/styles/default.css node_modules/highlight.js/styles/github.css node_modules/github-markdown-css/github-markdown.css | csso --output build/css/light.css",
  2. The path resolution library globby, that is being used to resolve markdown files, does not work with Windows-style paths.
    const files = await globby(filtered, { caseSensitiveMatch: false })

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

  • The fix for 1. is replacing both mkdirp and rimraf with the shx library, which, in addition to providing mkdir and rm commands, also provides a cat command. The commit is f5434da.
  • The fix for 2. is removing the library globby altogether (this may not be what you want), and letting Nodejs's core path module handle the paths. The commit is e10cbbd.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants