I built a Stencil app and when it was all done, I added Capacitor Electron to it. When I run the app:
stencil build npx cap sync npx cap open electron
The Electron container opens and the base index.html file loads, but as soon as it tries to load the first bundled .js file, I get the following error:
GET file:///D:/build/p-267af940.js net::ERR_FILE_NOT_FOUND
I read a bunch of the related posts here and on stack overflow and haven’t found a solution that works for me. For example, I tried changing the
<base href="./"> as mentioned in many of the articles, to no avail.
I’m fairly certain this is a content security policy issue, but I can’t find any guidelines anywhere about how to set it up correctly and this recent post is still unanswered: Looking for comprehensive content-security-policy guideline.
When I first launched the app, I got a security policy error which I searched for and found a recommendation to set it like this:
<meta http-equiv="Content-Security-Policy" content="script-src 'self';">
That fixed that issue, but now I can’t load any local files. I’ll start playing around with policy settings, but what’s the recommendation for Stencil, Capacitor, and Electron?