question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Describe the bug Preload not working, in both build and development mode.

Screenshots If applicable, add screenshots to help explain your problem. image image

Environment (please complete the following information):

  • OS and version: Ubuntu 18.04
  • node version: 10.16.2
  • vue-cli-plugin-electron-builder version : current
  • electron version: 6.0.0
  • other vue plugins used: typescript, vuetify, i18n
  • custom config for vcp-electron-builder:

    electronBuilder: {
      mainProcessFile: 'src/electron/background.ts',
      chainWebpackMainProcess: (config) => {
        config.resolve.alias.set('@', path.join(__dirname, 'src'));
        config.resolve.alias.set('@core', path.join(__dirname, 'core'));
        config.module.rule('wasm').test(/\.wasm$/).use('file-loader').loader('file-loader');
        config.module.rule('node').test(/\.node$/).use('node-loader').loader('node-loader');
      },
      mainProcessTypeChecking: true,
      builderOptions: {},
    },
  • (if possible) link to your repo: imposible

linked issue: https://github.com/nklayman/vue-cli-plugin-electron-builder/issues/89

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:17 (8 by maintainers)

github_iconTop GitHub Comments

3reactions
lahmidiamoumencommented, Dec 21, 2020

update your vue.config.js as so:

module.exports = { pluginOptions: { electronBuilder: { preload: ‘src/preload.js’, // Or, for multiple preload files: preload: { preload: ‘src/preload.js’, otherPreload: ‘src/preload2.js’ } } } }

2reactions
joe0BABcommented, Mar 22, 2021

Had the same issue. For me this was fixed by enabling the enableRemoteModule: true flag in the background.ts file, i.e., mainWindow = new BrowserWindow({ width: 800, height: 600, frame: false, webPreferences: { preload: path.join(__dirname, 'preload.js'), enableRemoteModule: true, nodeIntegration: true, } })

@nklayman Maybe this should be added to the documentation here.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Using Preload Scripts - Electron
In this part of the tutorial, you will learn what a preload script is and how to use one to securely expose privileged...
Read more >
How to use preload.js properly in Electron - Stack Overflow
The proper way to use the preload.js in Electron is to expose whitelisted ... Node.js is available in the Main, Preload, and Renderer....
Read more >
Electron process model explained (IPC, main, renderer and ...
Preload script contains code that will be executed in the renderer context, before its web content starts loading. This script is actually ran ......
Read more >
Electron Preload Script - Quasar Framework
However, you can run Node.js code and bridge it to the renderer thread through an Electron Preload script located at /src-electron/electron-preload.
Read more >
fix(plugin-webpack): use proper preload define for renderer by ...
Summarize your changes: Changes the preload define created for production renderer scripts so there is no longer a /renderer/renderer in the path.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found