File tree Expand file tree Collapse file tree 3 files changed +18
-6
lines changed
Expand file tree Collapse file tree 3 files changed +18
-6
lines changed Original file line number Diff line number Diff line change @@ -47,12 +47,7 @@ BASE_DIR = pathlib.Path(__file__).parent.parent
4747
4848os.environ.setdefault(" DJANGO_SETTINGS_MODULE" , " myproject.settings" )
4949
50- application = get_wsgi_application()
51- application = ESM(
52- application,
53- root = BASE_DIR / " staticfiles" / " esm" ,
54- prefix = " esm" ,
55- )
50+ application = ESM(get_wsgi_application())
5651```
5752
5853Finally, add the import map to your base template:
Original file line number Diff line number Diff line change @@ -37,10 +37,12 @@ def _resolve_importmap_urls(raw_importmap):
3737@register .simple_tag
3838def importmap ():
3939 global importmap_json
40+ print (not importmap_json or settings .DEBUG )
4041 if not importmap_json or settings .DEBUG :
4142 with (
4243 pathlib .Path (conf .get_settings ().STATIC_DIR ) / "importmap.json"
4344 ).open () as f :
4445 raw_importmap = json .load (f )
4546 importmap_json = _resolve_importmap_urls (raw_importmap )
47+ print (importmap_json )
4648 return mark_safe (importmap_json ) # nosec
Original file line number Diff line number Diff line change 22
33
44class ESM (WhiteNoise ):
5+ """Lightweight WSGI ES module loader based on whitenoise."""
6+
57 def immutable_file_test (self , path , url ):
68 return True
9+
10+ def __init__ (self , * args , ** kwargs ):
11+ from django .conf import settings # noqa: F401
12+
13+ super ().__init__ (
14+ * args ,
15+ ** {
16+ "root" : settings .BASE_DIR / "staticfiles" / "esm" ,
17+ "prefix" : "esm" ,
18+ "autorefresh" : settings .DEBUG ,
19+ }
20+ | kwargs ,
21+ )
You can’t perform that action at this time.
0 commit comments