Skip to content

svelte-kit preview ignores port and host in svelte.config.js #5335

@keithlayne

Description

@keithlayne

Describe the bug

Looking at https://github.com/sveltejs/kit/blob/master/packages/kit/src/cli.js#L167-L187 you can see from inspection that these two config entries will always be overwritten because the options are defaulted. svelte-kit dev doesn't share this problem because these options are not defaulted.

Reproduction

  1. Create a new sveltekit project via npm create svelte foobar
  2. Edit svelte.config.js and set config.kit.vite.preview.port to 3001
  3. Run e.g. npm run preview

Logs

Output: 


  SvelteKit v1.0.0-next.357

  local:   http://localhost:3000
  network: not exposed

  Use --host to expose server to other devices on this network

System Info

System:
    OS: Linux 5.17 Pop!_OS 22.04 LTS
    CPU: (16) x64 AMD Ryzen 7 PRO 5850U with Radeon Graphics
    Memory: 1.02 GB / 15.02 GB
    Container: Yes
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 16.13.1 - ~/.asdf/installs/nodejs/16.13.1/bin/node
    Yarn: 3.2.1 - ~/.asdf/shims/yarn
    npm: 8.1.2 - ~/.asdf/plugins/nodejs/shims/npm
    Watchman: 4.9.0 - /usr/bin/watchman
  Browsers:
    Chrome: 103.0.5060.53
    Firefox: 101.0.1
  npmPackages:
    @sveltejs/adapter-auto: next => 1.0.0-next.53 
    @sveltejs/adapter-static: ^1.0.0-next.34 => 1.0.0-next.34 
    @sveltejs/kit: next => 1.0.0-next.357 
    svelte: ^3.44.0 => 3.48.0 

Severity

annoyance

Additional Information

This is a mild annoyance but a trivial fix. The only reason this isn't a PR is because I don't see any obvious way to put tests around this. If you don't care, or can point me in the right direction, I'll send a PR.

I also saw the suggestion to stop using svelte-kit preview in favor of vite preview which looks like it would make this issue moot.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions