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

Electron app run shows raw index.html file not running app #517

Closed
timoplus opened this issue Nov 15, 2019 · 3 comments
Closed

Electron app run shows raw index.html file not running app #517

timoplus opened this issue Nov 15, 2019 · 3 comments

Comments

@timoplus
Copy link

timoplus commented Nov 15, 2019

I'm submitting Bug report

Current behavior

Using npm start runs the app in the browser.

npm run electron:build	Build desktop app
npm run electron:run	Run app on electron

The app loads in the Electron shell but displays the contents of the index.html file instead of the running app.

Expected behavior

App runs in the Electron window instead of showing the source.

Minimal reproduction of the problem with instructions

https://github.com/timoplus/web-electron-rocket

(This repo includes the answers to the creation questions in the readme.)

Environment

Windows 10.

@timoplus
Copy link
Author

timoplus commented Nov 26, 2019

I've noticed that if you choose View/Reload then the app runs correctly. Once running 'npm run electron:run' actually served the app in it's functional state, but all other times it displays the index.html file instead of running the app.

An observant dev might notice this in the electron.main.ts:

const liveReload = process.argv.slice(2).some(arg => arg === '--serve');
...
if (liveReload) {
    require('electron-reload')(__dirname, { electron: require(`${__dirname}/node_modules/electron`) });
    mainWindow.loadURL('http://localhost:4200');
    mainWindow.webContents.openDevTools();
  } else {
    // Load the index.html of the app.
    mainWindow.loadFile('dist.electron/index.html');
  }

So this behavior is by design. If you run the app with two flags like this then the app is run.

npm run electron:run -- --serve

@timoplus
Copy link
Author

This might still be an issue. Running the app with the -- --serve flags causes a blank screen. Running without the flags, as noted above, prints out the index.html, but refreshing the view runs the app.
However, I want to have a full screen app with no menu bar. When I have the solution to this issue I will report back here.

@timoplus
Copy link
Author

This is partially a duplicate of #507.
In that issue, it is noted that after doing an npm run build and npm run electron:run typing cmd-r refreshes the page and runs the app.

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

1 participant