diff --git a/rollup.config.js b/rollup.config.js index ce3c9eb..6a95234 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -6,6 +6,27 @@ import { terser } from 'rollup-plugin-terser'; const production = !process.env.ROLLUP_WATCH; +function serve() { + let server; + + function toExit() { + if (server) server.kill(0); + } + + return { + writeBundle() { + if (server) return; + server = require('child_process').spawn('npm', ['run', 'start', '--', '--dev'], { + stdio: ['ignore', 'inherit', 'inherit'], + shell: true + }); + + process.on('SIGTERM', toExit); + process.on('exit', toExit); + } + }; +} + export default { input: 'src/main.js', output: { @@ -52,20 +73,3 @@ export default { clearScreen: false } }; - -function serve() { - let started = false; - - return { - writeBundle() { - if (!started) { - started = true; - - require('child_process').spawn('npm', ['run', 'start', '--', '--dev'], { - stdio: ['ignore', 'inherit', 'inherit'], - shell: true - }); - } - } - }; -}