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

Environmental variables support for configuration files #1612

Open
leikoilja opened this issue Nov 23, 2024 · 4 comments
Open

Environmental variables support for configuration files #1612

leikoilja opened this issue Nov 23, 2024 · 4 comments
Labels
enhancement New feature or request

Comments

@leikoilja
Copy link

Is your feature request related to a problem? Please describe.
I cannot set various different settings dynamically for the build process.
Example: When i set analytics settings in quartz.config.ts i do it using hardcoded host and website ID

    analytics: {
      provider: "umami",
      host: "https://umami.example.com",
      websiteId: "111111111-20ee-4edc-1111-6e4ad1a1ed62",
    },

Describe the solution you'd like
being able to add .env.local file for local development build and set environmental variables on the hosting platform (Cloudflare pages for example).
And then reference those in quartz.config.ts file as process.env.UMAMI_HOST

@leikoilja leikoilja added the enhancement New feature or request label Nov 23, 2024
@saberzero1
Copy link
Collaborator

https://nodejs.org/en/learn/command-line/how-to-read-environment-variables-from-nodejs

Can't you just pass the environment file as parameter with --env-file?

@leikoilja
Copy link
Author

https://nodejs.org/en/learn/command-line/how-to-read-environment-variables-from-nodejs

Can't you just pass the environment file as parameter with --env-file?
that should work, thanks for the tip!
will try and get back here in a bit.

i guess an alternative approach would be to include https://github.com/motdotla/dotenv which would abstract it for .env* files to be automatically loaded into the runtime

@aarnphm
Copy link
Collaborator

aarnphm commented Nov 28, 2024

feel free to use that on your end. I don't think adding support to quartz makes sense.

env are somewhat hard to document over different CI setup. I think the philosophy of Quartz makes it very flexible to extend, for your own garden.

@leikoilja
Copy link
Author

https://nodejs.org/en/learn/command-line/how-to-read-environment-variables-from-nodejs

Can't you just pass the environment file as parameter with --env-file?

just tried, that approach does not work. the way the cli helpers like npx quartz build are build - they are not passing through additional options. For env variables support to work we'd need to change BuildArgv and add the actual logic of loading that file in the runtime processes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants