mirror of
https://github.com/inventree/InvenTree.git
synced 2025-04-29 20:16:44 +00:00
Fix new manifest path (#6814)
* fix manifest path * simplify * add falback for old path * fix var name * remove css lookup, not needed anymore * fix test path
This commit is contained in:
parent
32d161852a
commit
6ff4d5e035
@ -24,14 +24,20 @@ def spa_bundle(manifest_path: Union[str, Path] = '', app: str = 'web'):
|
|||||||
return f'{settings.STATIC_URL}{app}/{file}'
|
return f'{settings.STATIC_URL}{app}/{file}'
|
||||||
|
|
||||||
if manifest_path == '':
|
if manifest_path == '':
|
||||||
manifest_path = Path(__file__).parent.parent.joinpath(
|
manifest = Path(__file__).parent.parent.joinpath(
|
||||||
'static/web/manifest.json'
|
'static/web/.vite/manifest.json'
|
||||||
)
|
)
|
||||||
manifest = Path(manifest_path)
|
else:
|
||||||
|
manifest = Path(manifest_path)
|
||||||
|
|
||||||
if not manifest.exists():
|
if not manifest.exists():
|
||||||
logger.error('Manifest file not found')
|
# Try old path for manifest file
|
||||||
return
|
manifest = Path(__file__).parent.parent.joinpath('static/web/manifest.json')
|
||||||
|
|
||||||
|
# Final check - fail if manifest file not found
|
||||||
|
if not manifest.exists():
|
||||||
|
logger.error('Manifest file not found')
|
||||||
|
return
|
||||||
|
|
||||||
try:
|
try:
|
||||||
manifest_data = json.load(manifest.open())
|
manifest_data = json.load(manifest.open())
|
||||||
@ -40,13 +46,6 @@ def spa_bundle(manifest_path: Union[str, Path] = '', app: str = 'web'):
|
|||||||
return
|
return
|
||||||
|
|
||||||
return_string = ''
|
return_string = ''
|
||||||
# CSS (based on index.css file as entrypoint)
|
|
||||||
css_index = manifest_data.get('index.css')
|
|
||||||
if css_index:
|
|
||||||
return_string += (
|
|
||||||
f'<link rel="stylesheet" href="{get_url(css_index["file"])}" />'
|
|
||||||
)
|
|
||||||
|
|
||||||
# JS (based on index.html file as entrypoint)
|
# JS (based on index.html file as entrypoint)
|
||||||
index = manifest_data.get('index.html')
|
index = manifest_data.get('index.html')
|
||||||
dynamic_files = index.get('dynamicImports', [])
|
dynamic_files = index.get('dynamicImports', [])
|
||||||
|
@ -26,14 +26,11 @@ class TemplateTagTest(InvenTreeTestCase):
|
|||||||
def test_spa_bundle(self):
|
def test_spa_bundle(self):
|
||||||
"""Test the 'spa_bundle' template tag."""
|
"""Test the 'spa_bundle' template tag."""
|
||||||
resp = spa_helper.spa_bundle()
|
resp = spa_helper.spa_bundle()
|
||||||
self.assertTrue(
|
|
||||||
resp.startswith('<link rel="stylesheet" href="/static/web/assets/index')
|
|
||||||
)
|
|
||||||
shipped_js = resp.split('<script type="module" src="')[1:]
|
shipped_js = resp.split('<script type="module" src="')[1:]
|
||||||
self.assertTrue(len(shipped_js) > 0)
|
self.assertTrue(len(shipped_js) > 0)
|
||||||
self.assertTrue(len(shipped_js) == 3)
|
self.assertTrue(len(shipped_js) == 3)
|
||||||
|
|
||||||
manifest_file = Path(__file__).parent.joinpath('static/web/manifest.json')
|
manifest_file = Path(__file__).parent.joinpath('static/web/.vite/manifest.json')
|
||||||
# Try with removed manifest file
|
# Try with removed manifest file
|
||||||
manifest_file.rename(manifest_file.with_suffix('.json.bak')) # Rename
|
manifest_file.rename(manifest_file.with_suffix('.json.bak')) # Rename
|
||||||
resp = resp = spa_helper.spa_bundle()
|
resp = resp = spa_helper.spa_bundle()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user