From 32646bef516bf033d654583e8eec1272b962f357 Mon Sep 17 00:00:00 2001 From: Galen Date: Fri, 10 Jan 2025 11:52:14 -0800 Subject: [PATCH] create context processor for webpack manifest, re #11670 --- arches/app/utils/context_processors.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/arches/app/utils/context_processors.py b/arches/app/utils/context_processors.py index d43e4f11ee3..0970e285778 100644 --- a/arches/app/utils/context_processors.py +++ b/arches/app/utils/context_processors.py @@ -17,6 +17,8 @@ """ import json +import logging +import os from arches import __version__ from arches.app.models.models import GroupMapSettings, Language from arches.app.models.system_settings import settings @@ -24,6 +26,8 @@ from arches.app.utils.betterJSONSerializer import JSONSerializer from django.utils.translation import get_language, get_language_bidi +logger = logging.getLogger(__name__) + def livereload(request): return { @@ -109,3 +113,21 @@ def app_settings(request=None): "DEBUG": settings.DEBUG, } } + + +def webpack_manifest(request): + """ + Loads the webpack manifest.json and adds it to the template context. + """ + manifest_path = os.path.join( + settings.STATIC_ROOT, settings.STATIC_URL, "build", "manifest.json" + ) + manifest = {} + + if os.path.exists(manifest_path): + with open(manifest_path, "r") as f: + manifest = json.load(f) + else: + logger.warning("Webpack manifest not found at %s", manifest_path) + + return {"webpack_manifest": manifest}