Multiple Django apps with each having a react frontend

∥☆過路亽.° 提交于 2019-12-24 04:16:17

问题


I have a Django aplication (+REST framework) with pluggable Django apps (which are discovered using distutils' entry points, and can be developed independetly from each other, and installed via pip). This works well so far.

The main app should provide a basic index.html which dynamically loads React components, and each app should be possible to add React components as plugins, which are combined on the frontend then.

But: How the heck am I supposed to place my client directories into each app, so that they are found for collecting all the static files? Should I put a react app into /my-app1/client and /my-app2/client?

my-application/
  core-app/
    client/
      react files etc
    static/
    models.py
    ...
  plugin-app1/
    client/
      react files etc
    static/
    models.py
    ...

And tell Webpack/brunch/whatever to compile all the css/js etc files into /my-app1/static, followed by ./manage.py collectstatic then?

Is there a better approach to collect distributed react "plugin" in dfferent Django apps into one static directory? Can brunch.io do this? Webpack? Another? Own script?

It would be nice to have something like brunch watch - to have hot-updated all changed files instantly. This works for one directory, but not for a distributed net of plugin directories, right?

Or is this completely thought wrong? Please help.

来源:https://stackoverflow.com/questions/50796398/multiple-django-apps-with-each-having-a-react-frontend

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!