Vue-cli-plugin-electron-builder: Hot-Reload not working in background.js dependencies

Created on 6 May 2020  路  1Comment  路  Source: nklayman/vue-cli-plugin-electron-builder

Describe the bug
Hot-Reload wont work when despondencies of background.js changed.

To Reproduce
Steps to reproduce the behavior:

// src/background.ts
'use strict'

import path from 'path'
import { app, protocol, BrowserWindow, Tray, Menu, Notification } from 'electron'
import { createProtocol, installVueDevtools } from 'vue-cli-plugin-electron-builder/lib'
import { getConfig } from './common/config'

const isDevelopment = process.env.NODE_ENV !== 'production'

protocol.registerSchemesAsPrivileged([{ scheme: 'app', privileges: { secure: true, standard: true } }])

let win: BrowserWindow | null

function createWindow () {
  ...
}

if (app.requestSingleInstanceLock()) {
  app.on('ready', async () => {
    ... // Install Vue Devtools
    const config = getConfig()
    if (!config.hideOnStart) {
      createWindow()
    }
  })
  ...
} else {
  app.quit()
}

// src/common/config.ts

export function getConfig(){
  ...
}

Edit src/common/config.ts, but the background process wont be reloaded
Expected behavior
background process should be reloaded after its dependencies updated

Screenshots

Environment (please complete the following information):

Most helpful comment

You need to add the file to the mainProcessWatch array in vue.config.js:
```js
// vue.config.js

module.exports = {
pluginOptions: {
electronBuilder: {
// Provide an array of files that, when changed, will recompile the main process and restart Electron
// Your main process file will be added by default
mainProcessWatch: ['src/myFile1', 'src/myFile2'],
}
}
}

>All comments

You need to add the file to the mainProcessWatch array in vue.config.js:
```js
// vue.config.js

module.exports = {
pluginOptions: {
electronBuilder: {
// Provide an array of files that, when changed, will recompile the main process and restart Electron
// Your main process file will be added by default
mainProcessWatch: ['src/myFile1', 'src/myFile2'],
}
}
}

Was this page helpful?
0 / 5 - 0 ratings

Related issues

wakamin picture wakamin  路  3Comments

nklayman picture nklayman  路  3Comments

nickduskey picture nickduskey  路  3Comments

mrin9 picture mrin9  路  6Comments

Timibadass picture Timibadass  路  6Comments