Describe the bug
According to the Electron Builder documentation, it should be possible to include a preloader.js in order to utilize Node integration in the context of your Vue App. More explanation about Electron preloading can be found at Electron Documentation. When implementing mentioned solution to a clean installation of Vue.js and Electron Builder, I am unable to compile the application without errors occuring.
To Reproduce
Steps to reproduce the behavior:
Install Vue.js using vue create app with default settings. Install Electron builder using vue add electron-builder. Modify vue.config.js to contain:
// Create the browser window.
const win = new BrowserWindow({
width: 1280,
height: 720,
webPreferences: {
// Use pluginOptions.nodeIntegration, leave this alone
// See nklayman.github.io/vue-cli-plugin-electron-builder/guide/security.html#node-integration for more info
nodeIntegration: process.env.ELECTRON_NODE_INTEGRATION,
contextIsolation: !process.env.ELECTRON_NODE_INTEGRATION,
//How to add a preloader?
preload: path.join(__dirname, 'preload.js')//<-- This part was added
}
})
Expected behavior
A clear and concise description of what you expected to happen.
I expected the app to launch without any errors and/or warnings.
Screenshots
If applicable, add screenshots to help explain your problem.
I believe this would not be necessary.
Environment (please complete the following information):
Additional context
Add any other context about the problem here.
Error output:
Launching Electron...
(node:12076) ExtensionLoadWarning: Warnings loading extension at C:\Users\username\AppData\Roaming\app\extensions\ljjemllljcmogpfapbkkighbhhppjdbg:
Unrecognized manifest key 'browser_action'.
Unrecognized manifest key 'update_url'.
Permission 'contextMenus' is unknown or URL pattern is malformed.
Cannot load extension with file or directory name _metadata. Filenames starting with "_" are reserved for use by the system.
(Use `electron --trace-warnings ...` to show where the warning was created)
(node:12076) UnhandledPromiseRejectionWarning: ReferenceError: path is not defined
at createWindow (webpack:///./src/background.js?:32:16)
at App.eval (webpack:///./src/background.js?:70:3)
at processTicksAndRejections (internal/process/task_queues.js:93:5)
(node:12076) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). T
o terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:12076) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
Describe the bug According to the Electron Builder documentation, it should be possible to include a preloader.js in order to utilize Node integration in the context of your Vue App. More explanation about Electron preloading can be found at Electron Documentation. When implementing mentioned solution to a clean installation of Vue.js and Electron Builder, I am unable to compile the application without errors occuring.
To Reproduce Steps to reproduce the behavior:
Install Vue.js using
vue create app
with default settings. Install Electron builder usingvue add electron-builder
. Modifyvue.config.js
to contain:Modify background.js to contain:
Expected behavior A clear and concise description of what you expected to happen.
I expected the app to launch without any errors and/or warnings.
Screenshots If applicable, add screenshots to help explain your problem.
I believe this would not be necessary.
Environment (please complete the following information):
Not sure what is meant by this.
My repository could be found here: https://github.com/Barrosy/VueInElectron However, does not contain changes related to preloader yet.
vue info
:Additional context Add any other context about the problem here.
Error output: