Hot reload for plugin development?

Hi All. Apologies if this has been addressed (I didn’t find it):

Developing a discourse plugin on my local machine tends to be pretty slow. Each reload of my locally running app (to view code changes) takes over 5 seconds. So I make a change in an html/hbs or js file, hit save, then have to reload the app [edit: refresh the browser], and wait 5 seconds+ to view the change.

Is there any way to do hot reload (ie, automatic updating of the local view) for local discourse plugin development?

It seems like CSS files get updated automatically, but not html/hbs or js files.

Though I’m watching to see if there are any hints, I think that’s just the way it is. And from what I’ve seen, it’s much worse on a Mac.

2 Likes

Hey guys,

You should quite confidently only have to restart the server if your API has changed - ie your Ruby on Rails code.

If you’ve only changed the Javascript or HBS files, you can simply pick up the changes by refreshing the browser.

You will have noticed that CSS file changes don’t even require that! :slight_smile:

3 Likes

I’m talking here about refreshing the browser, and whether hot reload is available to avoid having to do that. It’s the browser refresh that takes 5+ seconds to view any change.

If I have to stop and reload the server (in the case that I change plugin.rb, for instance), that probably takes 60 seconds.

Hot reload is of course the standard for developing with many technologies today (I’m most familiar with Angular, which has this standard), and is awesome for development. I believe with Rails it’s possible through webpack (but not sure about that). My sense is hot reload is not available for discourse development, but wanted to check 'cause it would be awesome if it was available.

You need to refresh the browser to pick up updated javascript files

2 Likes

This will be coming with the EmberCLI: Coming to a Discourse near you!

7 Likes

In fact you can use Ember CLI with master Discourse right now to get this behaviour!

6 Likes

That sounds great, thanks. To use this for local development, is there anything I need to do other than download the latest version of discourse from github onto my computer?

1 Like

You’ll need to check out the latest discourse then do something like this:

  1. Start the api server: rails s

  2. Start the Ember server:

    1. Enter the right folder cd app/assets/javascript/discourse
    2. Install packages yarn
    3. Run ember CLI: ember serve --proxy "http://localhost:3000"

Then you can open http://localhost:4200 and you should be running in Ember CLI with hot reloading.

8 Likes

I was excited to upgrade my local discourse instance, and am now running 2.8 locally. But I am not yet able to get hot reload to work for html and js changes.

Here is how I run things:

cd into the discourse folder locally

$ redis-server //starts the server

$ rails s //starts the rails app

$ yarn //only run this the first time, I expect

$ bin/ember-cli //starts ember cli. The command ember serve--proxy "http://localhost:3000" gave me errors for some reason

This successfully has the app run at localhost:4200.

I have added in a plugin the local discourse instance, which is successfully displayed at localhost:4200. However, if I make changes to the html or js files, these changes are only displayed on the app running locally if I refresh the browser.

Do I have to do something else to have hot-reloading work?

2 Likes

Hi there. Is hot-reload available with ember-cli in Discourse? I am still having the same issue I mentioned in my previous post. Following those steps, I still do not get hot-reload (ie, I still have to refresh the browser to see changes to html and javascript, and ember-cli’s output in the terminal doesn’t seem to register when I hit save after a file change).