Electron - Not allowed to load local resource

后端 未结 10 1972
夕颜
夕颜 2020-12-28 14:05

Evening,
I\'m looking into using electron to package an existing angular2 build. I thought I had a dry run working but the actual packaging seems to be failing (see fina

10条回答
  •  忘掉有多难
    2020-12-28 14:43

    In case this helps anyone, the issue I was having was I had the path set using process.cwd():

    win.loadURL(`file://${process.cwd()}/dist/index.html`);
    

    Which when packaged is not correct since the the main.js file is not in the root anymore. Changing to __dirname:

    win.loadURL(`file://${__dirname}/dist/index.html`);
    

    Fixed the issue for me.

提交回复
热议问题