remove start:dev, put serve plugin in config file

This commit is contained in:
Richard Harris 2019-11-16 12:35:34 -05:00
parent a4666d3567
commit 7b0bb3279d
3 changed files with 20 additions and 17 deletions

View file

@ -16,7 +16,6 @@
"scripts": {
"build": "rollup -c",
"dev": "rollup -c -w",
"start": "sirv public --single",
"start:dev": "sirv public --single --dev"
"start": "sirv public --single"
}
}

View file

@ -3,7 +3,6 @@ import resolve from 'rollup-plugin-node-resolve';
import commonjs from 'rollup-plugin-commonjs';
import livereload from 'rollup-plugin-livereload';
import { terser } from 'rollup-plugin-terser';
import rollup_start_dev from './rollup_start_dev';
const production = !process.env.ROLLUP_WATCH;
@ -37,9 +36,9 @@ export default {
}),
commonjs(),
// In dev mode, call `npm run start:dev` once
// In dev mode, call `npm run start` once
// the bundle has been generated
!production && rollup_start_dev,
!production && serve(),
// Watch the `public` directory and refresh the
// browser on changes when not in production
@ -53,3 +52,20 @@ 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
});
}
}
};
}

View file

@ -1,12 +0,0 @@
import * as child_process from 'child_process';
let running_dev_server = false;
export default {
writeBundle() {
if (!running_dev_server) {
running_dev_server = true;
child_process.spawn('npm', ['run', 'start:dev'], { stdio: ['ignore', 'inherit', 'inherit'], shell: true });
}
}
};