Skip to content

Commit

Permalink
Update the Vite template tag to handle the new manifest shape
Browse files Browse the repository at this point in the history
  • Loading branch information
epicserve committed Dec 24, 2023
1 parent 7338139 commit 8d008ba
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
11 changes: 9 additions & 2 deletions apps/base/templatetags/vite.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,19 @@ def vite_asset(filename: str):
return get_script(filename)

manifest = get_manifest()
file_data = manifest.get(filename)
if is_css is True:
filename = filename.replace(".css", ".js")
file_data = manifest.get(filename)
else:
file_data = manifest.get(filename)

if file_data is None:
raise Exception(f'The vite asset "{filename}" was not found in the manifest file {VITE_MANIFEST_FILE}.')

filename = file_data["file"]
if is_css is True:
filename = file_data.get("css", [None])[0]
if filename is None:
raise Exception(f'The vite asset "{filename}" was not found in the manifest file {VITE_MANIFEST_FILE}.')
return get_css_link(filename)
return get_script(filename)

Expand Down
2 changes: 2 additions & 0 deletions config/settings/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,3 +299,5 @@
# MAINTENANCE MODE SETTINGS
MAINTENANCE_MODE_STATE_BACKEND = "maintenance_mode.backends.CacheBackend"
MAINTENANCE_MODE_STATE_BACKEND_FALLBACK_VALUE = True

VITE_DEV_MODE = env.bool("VITE_DEV_MODE", default=DEBUG)

0 comments on commit 8d008ba

Please sign in to comment.