How to load local html with its .js
and .css
dependencies with convertFileSrc
?
#9779
Unanswered
HuakunShen
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
convertFileSrc
could be used to load local html file into aWebviewWindow
.The
index.html
needs to load its dependenciesThese
.js
and.css
files cannot be loaded because the webview tries to loadasset://localhost/assets/index-BHYCjRZw.css
andasset://localhost/assets/index-CZGpdclX.js
. The absolute path is ignored.Is there a workaround for this to preserve the path? Changing the base url isn't a solution as the absolute path could be different for every computer.
If it is not possible with
convertFileSrc
, is there any other options?I managed to get this working by spawning a local static file server on another thread, but this doesn't seem to be the best solution.
Beta Was this translation helpful? Give feedback.
All reactions