lazy-load stuff

This commit is contained in:
Rich Harris
2018-03-10 23:00:36 -05:00
parent d8412f33ba
commit cddd7adaad
13 changed files with 81 additions and 88 deletions

View File

@@ -70,9 +70,20 @@ function create_hot_update_server(port: number, interval = 10000) {
return { send };
}
export default async function dev(port: number) {
export async function dev(opts: { port: number }) {
process.env.NODE_ENV = 'development';
let port = opts.port || +process.env.PORT;
if (port) {
if (!await ports.check(port)) {
console.log(clorox.bold.red(`> Port ${port} is unavailable`));
return;
}
} else {
port = await ports.find(3000);
}
const dir = dest();
rimraf.sync(dir);
mkdirp.sync(dir);