[Vuejs]-Electron with Vue disable auto reload

0👍

Disable on Main and Renderer processes

Remove the call of startElectron() in dev-runner.js > startMain().

function startMain () {
  return new Promise((resolve, reject) => {
    mainConfig.entry.main = [path.join(__dirname, '../src/main/index.dev.js')].concat(mainConfig.entry.main)
    mainConfig.mode = 'development'
    const compiler = webpack(mainConfig)

    compiler.hooks.watchRun.tapAsync('watch-run', (compilation, done) => {
      //Remove these lines and ...
      // logStats('Main', chalk.white.bold('compiling...'))
      // hotMiddleware.publish({ action: 'compiling' })
      done()
    })

    compiler.watch({}, (err, stats) => {
      if (err) {
        console.log(err)
        return
      }

      //... these lines.
      // logStats('Main', stats)
      //
      // if (electronProcess && electronProcess.kill) {
      //   manualRestart = true
      //   process.kill(electronProcess.pid)
      //   electronProcess = null
      //   startElectron()
      //
      //   setTimeout(() => {
      //     manualRestart = false
      //   }, 5000)
      // }

      resolve()
    })
  })
}

Disable only on Renderer process

Delete import line below from src/main/index.js.

import '../renderer/store';

This line is required by vuex-electron which makes vuex to run on main process. If you are not planning to use createPersistedState() or createSharedMutations(), you can delete this.

Leave a comment