Skip to content

Watch mode to rebuild all files & restart everything on file changes #16

Closed
@wilzbach

Description

@wilzbach

Hi,

So I am a big fan of tooling that auto-reloads everything on a change.
Thus I'm currently using this simple setup to automatically rebuild the JS and Python bundles + restart the web server.

1) Running webpack in watch mode

npx webpack --mode development -w

2) Rebuilding the meta information on every change

while true; do
    npm run build:py;
    inotifywait --event modify,create,delete,delete_self,close_write,move,move_self -q **/*.js ;
done
  1. Reloading the server on external changes

gunicorn supports this partially out of the box, e.g.

gunicorn --reload --reload-extra-file my_dash_component/ExampleComponent.py usage:server 

Though of course this won't refresh your browser.

Ideas

While for many users the webpack-serve (as part of npm run start) will do just fine, I think the user experience could be improved with:

  1. The metajson generation could be hooked into Webpack's lifecycle as a plugin (see e.g. https://webpack.js.org/concepts/plugins/) to achieve a single npm run app in an easy way.

2a) build:py could touch usage.py, s.t. even an out of the box Flask does a reload when a new meta extraction has been run
2b) Alternatively, one could pass the generated Python modules in my_dash_component to Flask as extra_files, s.t. its built-in reloader takes notice of them (see e.g. http://werkzeug.pocoo.org/docs/0.14/serving and http://flask.pocoo.org/docs/1.0/api/#flask.Flask.run)

  1. Not sure what your plans on supporting hot reloading in the browser with Dash, but that would make it awesome to develop (though I can see it's on your list: Dash Dev Tools dash#292)

What are your thoughts on this? (1) and (2) are easy and I would be happy to send quick PRs for this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions