saltyshiomix / nextron

⚡ Next.js + Electron ⚡
https://npm.im/nextron
MIT License
3.98k stars 229 forks source link

Question: ERR_FILE_NOT_FOUND #96

Closed danikaze closed 4 years ago

danikaze commented 4 years ago

I have a project to have a boilerplate based on nextron for the rest of my projects :P

So the thing is, I have a build working fine on dev, but when I run the app from the build I get this on the console

(node:21288) UnhandledPromiseRejectionWarning: Error: ERR_FILE_NOT_FOUND (-6) loading 'app://./home.html'
    at rejectAndCleanup (electron/js2c/browser_init.js:225:1288)
    at WebContents.failListener (electron/js2c/browser_init.js:225:1505)
    at WebContents.emit (events.js:223:5)

I know I'm doing something wrong, because the previous commit was working, but I can't find what. I'm messing with webpack configurations so probably it's there... but can't find what, so let me open this question here >_<

Diff

Might I ask for some help, Salty-san? :)

danikaze commented 4 years ago

Ok... SOLVED! In case it's useful for anybody... The problem was with CleanWebpackPlugin, because nextron does several builds, CleanWebpackPlugin is triggered several times, deleting the files created by the 1st build (main process) from the app folder when the 2nd build (renderer) is triggered...

So, I just needed to add the option cleanOnceBeforeBuildPatterns as

plugins.push(
  new CleanWebpackPlugin({
    protectWebpackAssets: false,
    cleanAfterEveryBuildPatterns: ['VERSION', 'COMMITHASH'], // I'm removing unneeded files from GitRevisionPlugin
    cleanOnceBeforeBuildPatterns: IS_PRODUCTION ? [] : undefined,
  })
);