-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Unable to set Vite mode in development #5162
Comments
We're actively working on this section of code right now and I wonder if we inadvertently broke something. Does this also happen with |
This bug does not appear to occur in |
I believe this should be fixed in @sveltejs/[email protected] |
I have just tested it, and it does indeed appear to be fixed. Thanks! |
Btw, this should be configured in vite.config.js rather than svelte.config.js -> kit -> vite. |
Describe the bug
It is supposed to be possible to set the Vite mode like this:
In production this works correctly, with
.env.<mode>
files being loaded andimport.meta.env.MODE === "custom"
However in development the mode seems to always be set to
"development"
..env.development
gets loaded, andimport.meta.env.MODE === "development"
, despite the setting.I do not know if this is a SvelteKit bug, a Vite bug, or that I am misunderstanding something about how Vite modes work. However I would expect this to always run with the Vite mode set to
"custom"
Reproduction
Set
kit -> vite -> mode
insvelte.config.js
to any string in the basic SvelteKit project created by the cli, and check the mode value usingimport.meta.env.MODE
.Build with
npm run svelte-kit build
and notice that the mode matches the string.But run a dev server with
npm run svelte-kit dev
and notice that the mode is"development"
A repository with a reproduction can be found here
This repo always sets the vite mode to
"custom"
, and displays the current vite mode in anh2
inindex.svelte
.Using
npm run build
and previewing withnpm run preview
shows that the mode was correctly set to"custom
".However when using
npm run dev
to run a dev server the mode is displayed as"development"
Logs
No response
System Info
Severity
serious, but I can work around it
Additional Information
I am trying to build my web app for both Github Pages and for Tauri, where the Tauri version can have more features. One way I am attempting to support this is using Vite modes to enable/disable/change features. Currently I am unable to test this in development, as the Vite mode is always giving
"development"
.In my actual repository I am setting an environment variable and changing the mode based on that env variable, as described in #1258 (via cross-env to work cross-platform)
The text was updated successfully, but these errors were encountered: