Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

__dirname in electron/main.ts references the root of the operating system #9

Closed
wilgnne opened this issue Jul 3, 2020 · 3 comments
Closed

Comments

@wilgnne
Copy link
Contributor

wilgnne commented Jul 3, 2020

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.

@wilgnne
Copy link
Contributor Author

wilgnne commented Jul 3, 2020

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.

webpack/webpack#1599

@diego3g
Copy link
Owner

diego3g commented Jul 5, 2020

Do i need to do something about this issue? Did you send a PR or something?

@wilgnne
Copy link
Contributor Author

wilgnne commented Jul 5, 2020

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.

webpack/webpack#1599

@wilgnne wilgnne closed this as completed Jul 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants