__dirname in electron/main.ts references the root of the operating system
Closed this issue · 3 comments
The following command does not work correctly in a production environment, as the __dirname variable indicates for the root of the operating system and not for the project entrypoint
if (process.env.NODE_ENV === 'development') {
mainWindow.loadURL('http://localhost:4000')
} else {
mainWindow.loadURL(
url.format({
pathname: path.join(__dirname, 'index.html'),
protocol: 'file:',
slashes: true
})
)
}
so it is not possible to access index.html
is there a simple way to remedy this? I'm working on a script to generate the production build.
solution found, the webpack has a __dirname flag
node: {
__dirname: false
},
that works for me, the setting seems counterintuitive. wish we had explanations for what true, false mean in each case.
Do i need to do something about this issue? Did you send a PR or something?
Already solved, I will close the issue
solution found, the webpack has a __dirname flag
node: { __dirname: false },
that works for me, the setting seems counterintuitive. wish we had explanations for what true, false mean in each case.