Watch main.js sources
This commit is contained in:
parent
6f4010edf2
commit
83b84f9fbd
|
@ -23,7 +23,8 @@
|
|||
"build:main": "cross-env NODE_ENV=production webpack --bail --config webpack.config.main.js",
|
||||
"build:renderer": "cross-env NODE_ENV=production webpack --bail --config webpack.config.renderer.js",
|
||||
"start": "electron src",
|
||||
"watch": "run-s watch:*",
|
||||
"watch": "run-p watch:*",
|
||||
"watch:main": "node scripts/watch_main_and_preload.js",
|
||||
"watch:renderer": "webpack-dev-server --config webpack.config.renderer.js",
|
||||
"serve": "gulp watch",
|
||||
"test": "npm-run-all build test:* lint:*",
|
||||
|
|
34
scripts/watch_main_and_preload.js
Normal file
34
scripts/watch_main_and_preload.js
Normal file
|
@ -0,0 +1,34 @@
|
|||
const webpack = require('webpack');
|
||||
const mainConfig = require('../webpack.config.main.js');
|
||||
const rendererConfig = require('../webpack.config.renderer.js');
|
||||
const electron = require('electron-connect').server.create({path: 'src'});
|
||||
|
||||
let started = false;
|
||||
|
||||
const mainCompiler = webpack(mainConfig);
|
||||
mainCompiler.watch({}, (err, stats) => {
|
||||
process.stdout.write(stats.toString({colors: true}));
|
||||
process.stdout.write('\n');
|
||||
if (!stats.hasErrors()) {
|
||||
if (started) {
|
||||
electron.restart();
|
||||
} else {
|
||||
electron.start();
|
||||
started = true;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
for (const key in rendererConfig.entry) {
|
||||
if (!key.startsWith('webview/')) {
|
||||
if ({}.hasOwnProperty.call(rendererConfig.entry, key)) {
|
||||
delete rendererConfig.entry[key];
|
||||
}
|
||||
}
|
||||
}
|
||||
const preloadCompiler = webpack(rendererConfig);
|
||||
preloadCompiler.watch({}, (err) => {
|
||||
if (err) {
|
||||
console.log(err);
|
||||
}
|
||||
});
|
Loading…
Reference in a new issue