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.

6 Likes