-
Notifications
You must be signed in to change notification settings - Fork 342
Closed
Description
Hi,
Thank you so much for creating this set up. I've always found doing asset hashing with Django quite daunting but your work makes it super easy.
That said, I have custom widgets in my code base for which I have webpack built javascript assets. Previously I've used the media option on the widget to provide the direct path to the asset but now that path needs to be dynamic. I've ended up writing the code as:
from webpack_loader.utils import get_loader
class VenueByNameWidget(VenueWidget):
url_name = 'venues:name-suggestions'
target_id = 'venue-name-suggestions'
js_app_name = 'venue-name-suggest-app'
@property
def media(self):
loader = get_loader('DEFAULT')
bundle = loader.get_bundle(self.js_app_name)
paths = tuple(map(lambda entry: webpack_loader.get_chunk_url(entry), bundle))
return widgets.Media(
js=paths
)But I felt that maybe there should be a webpack_loader.utils function to help with this?
I am no Django expert so I might be approaching the whole thing incorrectly but I wanted to share my experience. I'm happy to attempt a pull request if this would be useful.
Kind regards and thanks again,
Michael
Metadata
Metadata
Assignees
Labels
No labels