Merge pull request #566 from nolanlawson/nolan/issue-565

fix: fix "sapper export" with a custom PORT
This commit is contained in:
Rich Harris
2019-02-17 09:48:02 -04:00
committed by GitHub

View File

@@ -55,7 +55,8 @@ async function _export({
copy(path.join(build_dir, 'service-worker.js'), path.join(export_dir, 'service-worker.js'));
copy(path.join(build_dir, 'service-worker.js.map'), path.join(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}`;
@@ -196,4 +197,4 @@ async function _export({
function get_href(attrs: string) {
const match = /href\s*=\s*(?:"(.*?)"|'(.+?)'|([^\s>]+))/.exec(attrs);
return match[1] || match[2] || match[3];
}
}