Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feat] allow using Vite's strict.port option #2507

Merged
merged 1 commit into from
Sep 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/beige-trees-confess.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@sveltejs/kit': patch
---

[feat] allow using Vite's `strict.port: false` option
12 changes: 9 additions & 3 deletions packages/kit/src/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,6 @@ prog
.option('-H, --https', 'Use self-signed HTTPS certificate', false)
.option('-o, --open', 'Open a browser tab', false)
.action(async ({ port, host, https, open }) => {
await check_port(port);

process.env.NODE_ENV = process.env.NODE_ENV || 'development';
const config = await get_config();

Expand All @@ -102,7 +100,15 @@ prog
process.stderr.write(data);
});

welcome({ port, host, https, open });
if (!watcher.vite || !watcher.vite.httpServer) {
throw Error('Could not find server');
}
// we never start the server on a socket path, so address will be of type AddressInfo
const chosen_port = /** @type {import('net').AddressInfo} */ (
watcher.vite.httpServer.address()
).port;

welcome({ port: chosen_port, host, https, open });
} catch (error) {
handle_error(error);
}
Expand Down
3 changes: 2 additions & 1 deletion packages/kit/src/core/dev/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@ class Watcher extends EventEmitter {
server: {
fs: {
strict: true
}
},
strictPort: true
}
};

Expand Down