- Notifications
You must be signed in to change notification settings - Fork 4k
Livereload #234
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
Livereload #234
Conversation
| @davidagraf Thanks for the PR 👍 However, I think we shouldn't depend on the external addon, because that would minimize the number of users that would benefit from it and cause some confusion. What are your thoughts @SamyPesse ? |
| @AaronO I totally understand. To avoid the addon, we need to do this: https://github.com/gruntjs/grunt-contrib-watch#enabling-live-reload-in-your-html. I guess it need to be injected here somehow: https://github.com/davidagraf/gitbook/blob/master/theme/templates/page.html ... |
| I think it should be an external gitbook addon. Added by default, but addons are perfect for this (add a JS file to the build, ...). No modification should be done in the template file. So I think the best is to create a gitbook-plugin-livereload that inject the livereload.js, and add this addon by default when doing serve (really easy to do this). Take a look at this: https://github.com/GitbookIO/plugin-ga And once you're addon is ready, just add it to the package.json. |
| Hi, I created the plugin: https://github.com/davidagraf/gitbookio-plugin-livereload Does that look good? Now the question is: should I keep it on my account and create an npm package? Or do you guys wanna move it to the gitbookio account? |
| @davidagraf Thanks for the plugin. @SamyPesse I'm not sure it's best to have this a plugin, since it hooks into the So I'm not against this going into the core, if it's stable and doesn't degrade the experience for other users. |
| @AaronO @SamyPesse Any news/new opinions on this? |
| Sorry for taking so long to answer you. I think that the client side should be a plugin. The best will be to move it to the GitbookIO organization and add you as a collaborator of this repository if you're ok with that; and you can post it on NPM or I can if you prefer. |
| @SamyPesse No rush! Your proposal sound good to me! Will you move it to GitbookIO? I will post it on NPM as soon as you are done. Afterwards, I will update my pull request with the correct dependency. |
| You should be able to transfer ownership to the organisation, no? |
| Unfortunately, doesn't work because I do not have admin rights for GitbookIO. I guess you need to create a temp admin team: https://help.github.com/articles/how-to-transfer-a-repository#transferring-from-a-user-to-an-organization |
| An can you transfer ownership to my account (SamyPesse) (maybe add me as a collaborator before) and then I'll transfer ownership to GitbookIO |
| I just transfer the ownership, and I added you as a collaborator. Can you publish on npm and update the pr. |
| the npm is published, the pr updated |
| Thanks 👍 🍻 |
This PR introduces live-reloading in gitbook. When running 'gitbook serve', a tiny-lr server is started. As soon as the gitbook process restarts its 'normal' webserver (because of a file change), the tiny-lr server triggers a browser refresh.
Important: http://livereload.com/ needs to be installed in the browser to make the refreshing work. The livereload.js script import is not injected into index.html.
To make the livereload work smoother (to avoid "double refreshes"), I additionally introduced a option to disable the cache manifest generation.