Vue-cli-plugin-electron-builder: v2.0.0: Rename "background.js" to "main.js" and "main.js" to "renderer.js"

Created on 22 Dec 2019  ·  7Comments  ·  Source: nklayman/vue-cli-plugin-electron-builder

Wouldn't it make more sense to call main process as main.js and renderer process as renderer.js?
Right now it's kind of backwards.

Most helpful comment

I personally think it is fine. With that said, it is easy to achieve this in your project.

// vue.config.js

module.exports = {
  pages: {
    index: {
      entry: 'src/renderer.js' // Previously main.js
    }
  },
  pluginOptions: {
    electronBuilder: {
      mainProcessFile: 'src/main.js' // Previously background.js
    }
  }
}

All 7 comments

I personally think it is fine. With that said, it is easy to achieve this in your project.

// vue.config.js

module.exports = {
  pages: {
    index: {
      entry: 'src/renderer.js' // Previously main.js
    }
  },
  pluginOptions: {
    electronBuilder: {
      mainProcessFile: 'src/main.js' // Previously background.js
    }
  }
}

@AssetKid thanks for the code example. It's just unfortunate that I have to do that unnecessary monkey-wrenching or "patching" for the problem that shouldn't exist in the first place.

But I don't know, what's the point calling renderer process as main and main process as background (implying it is not main). It's not only confusing but essentially pointless.

The reason I don't change the name is because the renderer process uses main.js by default, and I think it would be confusing if I replaced it with a completely different file. You have the option to change it, but the default will remain background.js for now.

@nklayman what about renaming it to something reasonable: background.js to electronMain.js?

I tried renaming it myself by adding the @AssetKid code and changing "main" prop in package.json, but I'm getting this error:

This dependency was not found:

* [path_to_project_dir]\src\background.js in multi ./src/background.js

@AlexSHoffman You should only have to update the vue.config.js. Can you try following @AssetKid's suggestion with a blank repo? If it doesn't work can you upload it to Github and post a link so I can fix the issue.

Don't change the main value. It will not work.

Thanks guys, it works now

Was this page helpful?
0 / 5 - 0 ratings