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.

Hot-Reload not working in background.js dependencies

See original GitHub issue

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):

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

10reactions
nklaymancommented, May 7, 2020

You need to add the file to the mainProcessWatch array in vue.config.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'],
    }
  }
}
6reactions
nklaymancommented, Sep 21, 2021

@BroJenuel no, glob files are not supported for mainProcessWatch. However, you can add directories to that list and all contents will be watched.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Changes to transitive dependencies not triggering live reload
The LiveReload/HMR works as expected when changing the directly imported stylus file. It does not work when changing anything in the colors.styl ...
Read more >
chrome-extension-hot-reload - npm package
This is an npm package that can be imported in background.js and popup.js files to make hot reloading possible in extensions. Using this...
Read more >
MV3 service worker broken after auto-update and manual ...
Steps to reproduce the problem: 1.manual refresh extension 2.open new tab page and check service worker first time it should work ```js
Read more >
How to make your Node.js app restart automatically when you ...
This guide would show you how you can make your Node.js application reload automatically whenever you make changes to your code during ...
Read more >
live-server
No reload on changes. Open your browser's console: there should be a message at the top stating that live reload is enabled. Note...
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