更新electron到28.2.10,修复开发模式重启electron进程时偶现旧进程残留的问题
This commit is contained in:
@@ -4,6 +4,7 @@ module.exports = {
|
||||
modules: {
|
||||
localIdentName: isDev ? '[path][name]__[local]--[hash:base64:5]' : '[hash:base64:5]',
|
||||
exportLocalsConvention: 'camelCase',
|
||||
namedExport: false,
|
||||
},
|
||||
sourceMap: isDev,
|
||||
}
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
+10
-14
@@ -16,9 +16,10 @@ const rendererLyricConfig = require('./renderer-lyric/webpack.config.dev')
|
||||
const rendererScriptConfig = require('./renderer-scripts/webpack.config.dev')
|
||||
const { Arch } = require('electron-builder')
|
||||
const replaceLib = require('./build-before-pack')
|
||||
const treeKill = require('tree-kill')
|
||||
const { debounce } = require('./utils')
|
||||
|
||||
let electronProcess = null
|
||||
let manualRestart = false
|
||||
let hotMiddlewareRenderer
|
||||
let hotMiddlewareRendererLyric
|
||||
|
||||
@@ -135,6 +136,7 @@ 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 runElectronDelay = debounce(startElectron, 200)
|
||||
const compiler = webpack(mainConfig)
|
||||
|
||||
compiler.hooks.watchRun.tapAsync('watch-run', (compilation, done) => {
|
||||
@@ -146,23 +148,17 @@ function startMain() {
|
||||
compiler.watch({}, (err, stats) => {
|
||||
if (err) {
|
||||
console.log(err)
|
||||
reject(err)
|
||||
return
|
||||
}
|
||||
|
||||
// logStats('Main', stats)
|
||||
|
||||
if (electronProcess && electronProcess.kill) {
|
||||
manualRestart = true
|
||||
process.kill(electronProcess.pid)
|
||||
electronProcess = null
|
||||
startElectron()
|
||||
|
||||
setTimeout(() => {
|
||||
manualRestart = false
|
||||
}, 5000)
|
||||
}
|
||||
|
||||
resolve()
|
||||
if (electronProcess) {
|
||||
electronProcess.removeAllListeners()
|
||||
treeKill(electronProcess.pid)
|
||||
}
|
||||
runElectronDelay()
|
||||
})
|
||||
})
|
||||
}
|
||||
@@ -191,7 +187,7 @@ function startElectron() {
|
||||
})
|
||||
|
||||
electronProcess.on('close', () => {
|
||||
if (!manualRestart) process.exit()
|
||||
process.exit()
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
+18
-1
@@ -31,7 +31,12 @@ exports.mergeCSSLoader = beforeLoader => {
|
||||
esModule: false,
|
||||
},
|
||||
},
|
||||
'css-loader',
|
||||
{
|
||||
loader: 'css-loader',
|
||||
options: {
|
||||
esModule: false,
|
||||
},
|
||||
},
|
||||
'postcss-loader',
|
||||
],
|
||||
},
|
||||
@@ -63,3 +68,15 @@ exports.logStats = (proc, data) => {
|
||||
console.log(log)
|
||||
}
|
||||
|
||||
exports.debounce = (fn, delay = 100) => {
|
||||
let timer = null
|
||||
let _args
|
||||
return (...args) => {
|
||||
_args = args
|
||||
if (timer) clearTimeout(timer)
|
||||
timer = setTimeout(() => {
|
||||
timer = null
|
||||
fn(..._args)
|
||||
}, delay)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user