I have created a Django project with a React front-end. I'd like to reuse some of the Django apps and their corresponding React components, so I moved them to a separate Python package following the Django docs: Advanced tutorial: How to write reusable apps. The React components are in the static folders for each Django app and are included with the Python package.
The problem I'm running into is that after this new Python package is built and installed in a new Django project, to import a React component I have to import it from the Python package directory (site-packages). Is there a cleaner way to import the React components other than like this?
import Comp1A from 'venv/lib/python3.10/site-packages/app_pkg/app1/static/app1/js/comp1a';
This is problematic since the location of site-packages can vary from project to project. Is there at least a dynamic way to generate this path? I can use module.exports.resolve.alias in my webpack.config.js to only set it once in the project, but I would, at least, like to be able to generate the alias automatically.