fix: fix "sapper export" with a custom PORT

Fixes #565
This commit is contained in:
Nolan Lawson
2019-02-15 18:50:34 -08:00
parent 82e637ea7c
commit 795da23418

View File

@@ -60,7 +60,8 @@ async function _export({
sander.copyFileSync(build_dir, 'service-worker.js.map').to(export_dir, 'service-worker.js.map');
}
const port = await ports.find(3000);
const defaultPort = process.env.PORT ? parseInt(process.env.PORT) : 3000;
const port = await ports.find(defaultPort);
const protocol = 'http:';
const host = `localhost:${port}`;
@@ -199,4 +200,4 @@ async function _export({
function get_href(attrs: string) {
const match = /href\s*=\s*(?:"(.*?)"|'(.+?)'|([^\s>]+))/.exec(attrs);
return match[1] || match[2] || match[3];
}
}