Skip to content

Commit 9915792

Browse files
author
Andreas H. Kelch
committedSep 18, 2024·
feat: auto detect development server
1 parent 568cd16 commit 9915792

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed
 

‎deploy/html/template.html

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
{% set development = True %}
21
<!DOCTYPE html>
32
<html lang="de">
43
<head>
@@ -7,7 +6,7 @@
76
{%- block additionalhead %}
87

98
{% endblock %}
10-
{{inject_vite(development)}}
9+
{{inject_vite()}}
1110
</head>
1211
<body>
1312
<div id="vite_context">

‎deploy/render/__init__.py

+9-2
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,19 @@ def _postProcessAppObj(obj):
1717

1818
import typing as t
1919
import json as _json
20-
import logging
20+
import logging, requests
2121
from viur.core.render.html.utils import jinjaGlobalFunction
2222
@jinjaGlobalFunction
23-
def inject_vite(render, development: bool = False) -> t.Any:
23+
def inject_vite(render, development: bool | None = None) -> t.Any:
2424
"""build vue imports from manifest"""
2525

26+
if development is None:
27+
try:
28+
resp = requests.get("http://localhost:8081")
29+
development = resp.status_code == 200
30+
except Exception as e:
31+
development = False
32+
2633
if development:
2734
return """<script type="module" src="http://localhost:8081/@vite/client"></script>
2835
<script type="module" src="http://localhost:8081/main.js"></script>"""

0 commit comments

Comments
 (0)
Please sign in to comment.