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
47
47
48
48
os.environ.setdefault(" DJANGO_SETTINGS_MODULE" , " myproject.settings" )
49
49
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())
56
51
```
57
52
58
53
Finally, 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):
37
37
@register .simple_tag
38
38
def importmap ():
39
39
global importmap_json
40
+ print (not importmap_json or settings .DEBUG )
40
41
if not importmap_json or settings .DEBUG :
41
42
with (
42
43
pathlib .Path (conf .get_settings ().STATIC_DIR ) / "importmap.json"
43
44
).open () as f :
44
45
raw_importmap = json .load (f )
45
46
importmap_json = _resolve_importmap_urls (raw_importmap )
47
+ print (importmap_json )
46
48
return mark_safe (importmap_json ) # nosec
Original file line number Diff line number Diff line change 2
2
3
3
4
4
class ESM (WhiteNoise ):
5
+ """Lightweight WSGI ES module loader based on whitenoise."""
6
+
5
7
def immutable_file_test (self , path , url ):
6
8
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