2
0
mirror of https://github.com/frappe/books.git synced 2024-12-26 20:30:25 +00:00
books/webpack/start.js

25 lines
766 B
JavaScript
Raw Normal View History

const { spawn } = require('child_process');
const { startWebpackDevServer } = require('./serve');
const { getAppConfig, resolveAppDir } = require('./utils');
const appConfig = getAppConfig();
module.exports = function start(mode) {
2018-10-20 12:30:58 +00:00
process.env.NODE_ENV = 'development';
2018-10-20 12:30:58 +00:00
if (mode === 'electron') {
const electron = require('electron');
const electronPaths = appConfig.electron.paths;
2018-10-20 12:30:58 +00:00
startWebpackDevServer()
.then((devServer) => {
const p = spawn(electron, [resolveAppDir(electronPaths.mainDev)], { stdio: 'inherit' })
p.on('close', () => {
devServer.close();
});
});
} else {
const nodePaths = appConfig.node.paths;
2018-10-20 12:30:58 +00:00
spawn('node', [resolveAppDir(nodePaths.main)], { stdio: 'inherit' })
}
}