Fix vite_entry for debug environment
This commit is contained in:
parent
469a3988e2
commit
eefdd093b2
1 changed files with 7 additions and 5 deletions
10
web/app.py
10
web/app.py
|
|
@ -37,20 +37,22 @@ class FlaskUser(UserMixin):
|
||||||
def get_id(self):
|
def get_id(self):
|
||||||
return self.db_user.telegram_username
|
return self.db_user.telegram_username
|
||||||
|
|
||||||
with open("web/static/.vite/manifest.json") as f:
|
try:
|
||||||
|
with open("web/static/.vite/manifest.json") as f:
|
||||||
vite_manifest = json.load(f)
|
vite_manifest = json.load(f)
|
||||||
|
except FileNotFoundError:
|
||||||
|
vite_manifest = None
|
||||||
|
|
||||||
@app.context_processor
|
@app.context_processor
|
||||||
def inject_vite_entry():
|
def inject_vite_entry():
|
||||||
def vite_entry(file):
|
def vite_entry(file):
|
||||||
if app.debug:
|
if vite_manifest is None:
|
||||||
return Markup(
|
return Markup(
|
||||||
dedent(f"""
|
dedent(f"""
|
||||||
<script type="module" src="{DEBUG_VITE_PREFIX}@vite/client"></script>
|
<script type="module" src="{DEBUG_VITE_PREFIX}@vite/client"></script>
|
||||||
<script type="module" src="{DEBUG_VITE_PREFIX}{file}"></script>
|
<script type="module" src="{DEBUG_VITE_PREFIX}{file}"></script>
|
||||||
""").strip())
|
""").strip())
|
||||||
else:
|
elif file in vite_manifest:
|
||||||
if file in vite_manifest:
|
|
||||||
src = vite_manifest[file]['file']
|
src = vite_manifest[file]['file']
|
||||||
result = f'<script type="module" src="{PROD_VITE_PREFIX}{src}"></script>'
|
result = f'<script type="module" src="{PROD_VITE_PREFIX}{src}"></script>'
|
||||||
if('css' in vite_manifest[file]):
|
if('css' in vite_manifest[file]):
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue