capacitor-community / electron

Deploy your Capacitor apps to Linux, Mac, and Windows desktops, with the Electron platform! 🖥️
https://capacitor-community.github.io/electron/
MIT License
318 stars 58 forks source link

Building app with electron:pack - resulting app shows blank page and error in console #211

Open tommykjensen opened 1 year ago

tommykjensen commented 1 year ago

I have created a project with ionic start, template sidemenu.

Then I added electron following the get started steps. npm i @capacitor-community/electron npx cap add @capacitor-community/electron

When running the app with the npx cap open command the starts and the app works.

If I then build a mac application with the command electron:pack and execute the resulting file then the app start but with a blank page.

In the console log following error is displayed:

Uncaught EvalError: Refused to evaluate a string as JavaScript because 'unsafe-eval' is not an allowed source of script in the following Content Security Policy directive: "default-src capacitor-electron://* 'unsafe-inline' data:".

Platform: Mac Studio M1, Monterey 12.4

ps if I use the git repository "angular-electron" by Maxine Griss and build the app it works. But in that case I have big troubles adding the Ionic framework :-( I really would like to use Ionic in a electron app.

JuliusSkrisa commented 1 year ago

@tommykjensen go to steup.ts in electron/src and add 'unsafe-eval' to 'Content-Security-Policy' string. "default-src capacitor-electron://* 'unsafe-inline' data: 'unsafe-eval' "

if you dont want to use unsafe-eval, check this up: https://content-security-policy.com/examples/electron/