Description
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
- 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:
- 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)
- 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.