[英]Electron main process not loading other files once compiled with Electron Builder
index.html
file and consequently the renderer.js
file.index.html
文件,因此不再加载renderer.js
文件。__dirname
as well as relative/absolute file paths but I cannot get it to work__dirname
以及相对/绝对文件路径的组合,但我无法让它工作git clone
cd electron-builder-error
yarn install
yarn webpack
yarn dev (works fine)
yarn prod (builds fine)
Run the installer
Open the program and notice that everything is blank
At your main.js
在你的
main.js
function createWindow(): void {
const win = new BrowserWindow({
width: 800,
height: 600,
webPreferences: {
nodeIntegration: true,
webSecurity: false
}
})
win.loadFile(process.env.NODE_ENV === 'development'? './index.html' : './compiled/index.html' )
}
And you should pass the NODE_ENV
variable at your webpapck configuration.您应该在 webpapck 配置中传递
NODE_ENV
变量。 Normally, this is set as production
So when you run as dev without setting NODE_ENV
then it won't work.通常,这被设置为
production
所以当你在没有设置NODE_ENV
情况下作为开发者运行时,它将无法工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.