leo / electron-next-skeleton

An example Electron app built with Next.js
https://leo.im/2017/electron-next
MIT License
177 stars 31 forks source link

Production version not working #2

Open ghost opened 6 years ago

ghost commented 6 years ago

I did a clean clone of the repo, installed packages, then ran npm run dist. When I open the webpage I get an error: Not allowed to load local resource: .../ElectronNext.app/Contents/Resources/app.asar/renderer/out/start/index.html

To fix this, i disabled web security on the mainBrowser window:

const mainWindow = new BrowserWindow({
    width: 800,
    height: 600,
    webPreferences: {
      webSecurity: false
    }
})

The error is gone, but now the app loads a blank screen.

What might be the problem?

ghost commented 6 years ago

I've spotted a couple of problems so far:

  1. You can't have await running in production app. It has to be done on with dev: isDev? await() : '';
  2. The index.html file generated by next export has references to /_next which, on production app, will point to file:///_next which obviously doesn't exist. All references must have the first / removed from them.
  3. The _next folder also needs to be under the start folder.

The first one is trivial to solve. The second and third have to be fixed manually everytime a new build is made. I'm not sure yet how to proceed next to make it automatic.

Tzelon commented 6 years ago

Just tried to build for production. everything seems to be working.

realtebo commented 5 years ago

Hi !

I can confirm issues with your boilerblate

I am on windows 10 pro, with node 10 and npm 6

npm install is running fine

Also npm start works well, and hot reloading is marveillous when seen working inside an electron app !

But when running npm run dist I got an error, because bundle is not a valid command

E:\next_js\electron-next-skeleton>npm run dist

> electron-next-skeleton@1.0.0 dist E:\next_js\electron-next-skeleton
> npm run build && bundle

> electron-next-skeleton@1.0.0 build E:\next_js\electron-next-skeleton
> next build renderer && next export renderer

> Using "webpack" config function defined in next.config.js.
  using build directory: E:\next_js\electron-next-skeleton\renderer\.next
  exporting path: /start

"bundle" non è riconosciuto come comando interno o esterno,
 un programma eseguibile o un file batch.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! electron-next-skeleton@1.0.0 dist: `npm run build && bundle`
npm ERR! Exit status 1
realtebo commented 5 years ago

PS: please update the code, to use last version of all dependencies !