Skip to content

Conversation

@davidagraf
Copy link

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.

@AaronO
Copy link

AaronO commented May 15, 2014

@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 ?

@davidagraf
Copy link
Author

@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 ...

@SamyPesse
Copy link
Member

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.

@davidagraf
Copy link
Author

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?

@AaronO
Copy link

AaronO commented May 15, 2014

@davidagraf Thanks for the plugin.

@SamyPesse I'm not sure it's best to have this a plugin, since it hooks into the serve command it's not really a typical plugin.

So I'm not against this going into the core, if it's stable and doesn't degrade the experience for other users.

@davidagraf
Copy link
Author

@AaronO @SamyPesse Any news/new opinions on this?

@SamyPesse
Copy link
Member

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.

@davidagraf
Copy link
Author

@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.

@SamyPesse
Copy link
Member

You should be able to transfer ownership to the organisation, no?

@davidagraf
Copy link
Author

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

@SamyPesse
Copy link
Member

An can you transfer ownership to my account (SamyPesse) (maybe add me as a collaborator before) and then I'll transfer ownership to GitbookIO

@SamyPesse
Copy link
Member

I just transfer the ownership, and I added you as a collaborator.

Can you publish on npm and update the pr.

@davidagraf
Copy link
Author

the npm is published, the pr updated

SamyPesse added a commit that referenced this pull request May 21, 2014
@SamyPesse SamyPesse merged commit 8d6923c into GitbookIO:master May 21, 2014
@SamyPesse
Copy link
Member

Thanks 👍 🍻

@davidagraf davidagraf deleted the livereload branch May 22, 2014 05:23
SamyPesse added a commit that referenced this pull request Jun 12, 2014
SamyPesse added a commit that referenced this pull request Mar 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants