Skip to content

Commit

Permalink
Merge pull request sveltejs#89 from sveltejs/remove-start-dev
Browse files Browse the repository at this point in the history
remove start:dev, put serve plugin in config file
  • Loading branch information
Rich-Harris authored Nov 16, 2019
2 parents a4666d3 + 7b0bb32 commit bcc87d1
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 17 deletions.
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
22 changes: 19 additions & 3 deletions rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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
Expand All @@ -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
});
}
}
};
}
12 changes: 0 additions & 12 deletions rollup_start_dev.js

This file was deleted.

0 comments on commit bcc87d1

Please sign in to comment.