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

CLI ignores Vite server config #2165

Closed
dreitzner opened this issue Aug 11, 2021 · 3 comments · Fixed by #2232
Closed

CLI ignores Vite server config #2165

dreitzner opened this issue Aug 11, 2021 · 3 comments · Fixed by #2232
Labels
feature / enhancement New feature or request p2-nice-to-have SvelteKit cannot be used by a small number of people, quality of life improvements, etc.

Comments

@dreitzner
Copy link
Contributor

Describe the bug

packages\kit\src\cli.js => async function get_Config() does not load the vite part of the config.

Therefore the params for server (like host, port, open, https,...) are ignored.

Solution:

  • read vite config
  • overwrite values in cli

Reproduction

import preprocess from 'svelte-preprocess';

/** @type {import('@sveltejs/kit').Config} */
const config = {
	// Consult https://github.com/sveltejs/svelte-preprocess
	// for more information about preprocessors
	preprocess: preprocess(),

	kit: {
		// hydrate the <div id="svelte"> element in src/app.html
		target: '#svelte',
		vite: {
			server: {
				port: 987,
			}
		}
	}
};

export default config;

will not open server on port 987.

Logs

No response

System Info

System:
    OS: Windows 10 10.0.19042
    CPU: (8) x64 Intel(R) Core(TM) i7-8550U CPU @ 1.80GHz
    Memory: 4.02 GB / 15.88 GB
  Binaries:
    Node: 14.17.2 - ~\AppData\Local\Volta\tools\image\node\14.17.2\node.EXE
    Yarn: 1.5.1 - C:\Program Files\Volta\yarn.EXE
    npm: 6.14.13 - ~\AppData\Local\Volta\tools\image\node\14.17.2\npm.CMD
  Browsers:
    Chrome: 92.0.4515.131
    Edge: Spartan (44.19041.906.0), Chromium (92.0.902.67)
    Internet Explorer: 11.0.19041.1
  npmPackages:
    @sveltejs/kit: next => 1.0.0-next.146
    svelte: ^3.34.0 => 3.42.1

Severity

annoyance

Additional Information

No response

@dominikg
Copy link
Member

sveltekit uses vite in middleware mode during dev. As a result not all of vite's config options are going to be used/effective and host/port are not because there is no classic "vite server" started by vite's cli

Currently the only option to customize sveltekit port is via cli flag

Not reading the port from vite config isn't a bug imho. If you want to be able to customize host/port from the config, a feature request to add new options to the kit namespace would be more appropriate.

@benmccann
Copy link
Member

I'm not sure what to do with port in the config file because it'd only be used in dev mode, which might be confusing? In production, you can specify it in the config already in the adapter. I think for port it'd probably just be better for users to add it to the dev script in package.json

Maybe we should log a warning if people try to set options under the server config section? Though the one thing I do think we take from there right now is SSL cert config

@Conduitry
Copy link
Member

HMR server/port config from the Vite config is also respected, which is under server. I think it makes sense to emit warnings (or errors?) for config we know will be ignored.

@Conduitry Conduitry added feature / enhancement New feature or request p2-nice-to-have SvelteKit cannot be used by a small number of people, quality of life improvements, etc. labels Aug 11, 2021
@benmccann benmccann linked a pull request Aug 21, 2021 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature / enhancement New feature or request p2-nice-to-have SvelteKit cannot be used by a small number of people, quality of life improvements, etc.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants