Skip to content

environment variables not working #2664

Discussion options

You must be logged in to vote

Good question: refer to this documentation: https://www.snowpack.dev/reference/environment-variables

Snowpack grabs env variables directly from your process.env. There are a few ways to add them to your app:

  1. Add them before any command: SNOWPACK_PUBLIC_TEST=yolo snowpack dev
  2. Add them to the top of your config file: process.env.SNOWPACK_PUBLIC_TEST = 'yolo'; // ... rest of your config file
  3. Use a plugin to load from a .env file: https://www.npmjs.com/package/@snowpack/plugin-dotenv

Re-reading the docs, I can see how this could be more clear! Would love anyone to add a PR to clarify that page of the docs

Replies: 3 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@geddski
Comment options

Answer selected by geddski
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
4 participants