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):
|
||||
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)
|
||||
except FileNotFoundError:
|
||||
vite_manifest = None
|
||||
|
||||
@app.context_processor
|
||||
def inject_vite_entry():
|
||||
def vite_entry(file):
|
||||
if app.debug:
|
||||
if vite_manifest is None:
|
||||
return Markup(
|
||||
dedent(f"""
|
||||
<script type="module" src="{DEBUG_VITE_PREFIX}@vite/client"></script>
|
||||
<script type="module" src="{DEBUG_VITE_PREFIX}{file}"></script>
|
||||
""").strip())
|
||||
else:
|
||||
if file in vite_manifest:
|
||||
elif file in vite_manifest:
|
||||
src = vite_manifest[file]['file']
|
||||
result = f'<script type="module" src="{PROD_VITE_PREFIX}{src}"></script>'
|
||||
if('css' in vite_manifest[file]):
|
||||
|
|
|
|||
Loading…
Reference in a new issue