| 21 Dec 2023 |
Lily Foster | In reply to @peter-lustig:matrix.org because what i really wonder is why npm run build works and nix build errors out there is no npm/nix difference here. the difference is you are baking in variables that you are making available in your local env but not in your build env | 16:08:51 |
Lily Foster | In reply to @peter-lustig:matrix.org because what i really wonder is why npm run build works and nix build errors out * there is no npm/nix difference here. the difference is you are baking in variables that you are making available in your local env but not in your nix build env | 16:08:55 |
Lily Foster | from what i can tell anyway | 16:09:10 |
peter-lustig | In reply to @lily:lily.flowers i mean again, the fake values will let it build, but if it's baking them in, it won't work. you could put real values in there but then you'd have world-readable secrets for runtime i am passing the env variables via dotenv and command line arguments with agenix, so to be honest I just need to have it building | 16:09:11 |
peter-lustig | lemme try the fake values | 16:09:26 |
Lily Foster | In reply to @peter-lustig:matrix.org for runtime i am passing the env variables via dotenv and command line arguments with agenix, so to be honest I just need to have it building yeah but svelte explicitly says the values are baked in at build time. how would it be grabbing them at runtime if you don't have other code to do such? | 16:09:46 |
Lily Foster |
If the user lands on a prerendered page, SvelteKit will request up-to-date values for $env/dynamic/public from the server (by default from a module called _env.js ...)
| 16:10:14 |
Lily Foster | ah | 16:10:15 |
Lily Foster | that sounds .... weird. but that does mean fake values might work? | 16:10:26 |
peter-lustig | I will try now xd | 16:10:37 |
Lily Foster | i do hope it is that simple! | 16:11:21 |
Lily Foster | not sure how many variables you have in the file, but you will likely need to define all of them | 16:11:46 |
Lily Foster | i wonder why svelte doesn't have a way to say "this won't be needed at build time, just put a blank value in" | 16:12:02 |
peter-lustig | just four | 16:12:08 |
peter-lustig | In reply to @lily:lily.flowers i wonder why svelte doesn't have a way to say "this won't be needed at build time, just put a blank value in" idk maybe they do but not many people use sveltekit compared to react for example so finding stuff out is usually difficult | 16:12:34 |
Lily Foster | In reply to @peter-lustig:matrix.org idk maybe they do but not many people use sveltekit compared to react for example so finding stuff out is usually difficult that's pretty fair tbh, i could totally see that | 16:12:53 |
peter-lustig | ok so now the stuff builds | 16:13:05 |
peter-lustig | i guess it would just work now, let me test this in production | 16:13:13 |
peter-lustig | In reply to @lily:lily.flowers there is no npm/nix difference here. the difference is you are baking in variables that you are making available in your local env but not in your nix build env ah i thought nix could read my local .env file | 16:13:49 |
peter-lustig | with some magic xd | 16:15:58 |
peter-lustig | Okayyy Lily Foster, so this does not work | 16:16:47 |
peter-lustig | now in production the variables are also empty strings apparently | 16:16:59 |
Lily Foster | i was worried about that | 16:17:29 |
Lily Foster | let me dive more into the svelte docs | 16:17:38 |
Lily Foster | because you should be pulling these values at runtime rather than build time, and ideally not even require them to be set at all during build time. but idk svelte | 16:18:00 |
Lily Foster | * because you should be pulling these values at runtime rather than build time, and ideally not even require them to be set at all during build time. but idk very much about svelte | 16:18:05 |
Lily Foster |
by default from a module called _env.js — this can be configured with config.kit.env.publicModule
do you know what this part of the doc you mentioned means?
| 16:19:14 |
Lily Foster | is that how env vars should be passed in at runtime? | 16:19:22 |
peter-lustig | that line confused me too | 16:19:38 |
Lily Foster | wait, i just realized, does this mean you are importing these vars into client-side code, if it is attempting to pre-render it? | 16:20:24 |