-
Notifications
You must be signed in to change notification settings - Fork 368
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
Feature(command-dev): --toml <path-to-toml> #1599
Comments
EDIT: note that I slightly modified the described. Continued in #1599 (comment) I was able to find a reasonable workaround here, since I found that my Create React App based application server could own proxying to the deployed production where redirects were then configured to work as needed: https://create-react-app.dev/docs/proxying-api-requests-in-development/ Changes I made from proposed above:
This means that if I were to inadvertently commit netlify.toml with the contents of netlify.development.toml, no secrets would enter version control. If I inadvertently pushed, Netlify would fail to find a It does mean that I have an added inconvenience of having to Based on what I see here #640 it sounds like Netlify Dev does not intend to process Here is my netlify.development.toml:
|
Hi @bdefore, thank you for the detailed description. Can you outline the specific |
I believe @bdefore is using token replacements within [[Redirects]], similar to us:
Since Netlify does not support using environment variables here, the suggested approach is to preprocess the netlify.toml file as part of the build, which is what we do, see here: https://docs.netlify.com/configure-builds/file-based-configuration/#inject-environment-variable-values We would like to maintain the netlify.toml file, so being able to pass in a reference to an already-processed netlify.dev.toml file to netlify dev would be useful for this use case. |
+1 - having a different workflow for build and dev is not desirable. Other services already have the option of referencing outside environment variables in their build configuration files. |
I still use the above workaround, but inverted. A base configuration needed for Netlify Dev constitutes my netlify.toml. When running in Netlify's CI my first step is to append supplemental configuration required for a deployed environment, such as redirects. These live in a netlify.ci.toml and I just |
Is your feature request related to a problem? Please describe.
Using environment variables in netlify.toml is not supported. Firstly, I find this to be a prominent shortcoming of the Netlify service, and if this were supported, this feature request would be unnecessary.
Some of my site's settings here are either secrets that I don't want in version control or benefit from dynamic assignments, so I use a workaround similar to the last option in https://docs.netlify.com/configure-builds/file-based-configuration/#inject-environment-variable-values
I began with sed replacement as Netlify suggested, but soon found it error prone and unwieldy, so I made a Node script: https://gist.github.com/bdefore/29a40a1028cf414fe51c1b39686765bc (in this file I populate the contents of
required
andoptional
with variables relevant to my site).My configuration for
command
in netlify.toml is:CI= yarn run build:replace && CI= yarn run build
and this works well during deployments, replacing placeholders with those specified in site configuration.Where this becomes problematic is when I want to run Netlify Dev, which would rely on a replaced version of netlify.toml. I currently must run the rewrite script locally once before starting Netlify Dev:
"build:replace:dev": "netlify dev:exec babel-node rewrite_netlify_vars.js"
, in particular because I rely on netlify.toml for[redirects]
blocks even in local development.This replaces placeholder values in netlify.toml but since the file is managed by git, there is a risk of accidentally committing the changes and leaking secrets into version control.
Describe the solution you'd like
I'd like to have a .gitignore'd netlify.development.toml which is the output of a replace run, and be able to run
netlify dev --toml netlify.development.toml
.Alternatively, the
[dev]
block could support alocalOverrides
that is a path to another toml that is internally merged before Netlify Dev runs.Describe alternatives you've considered
local
branch that is regularly rebased withmaster
and is blocked from being pushedAdditional context
Related discussion that proposes ability to override toml values individually: #1265
Related discussion about supporting environment variables in netlify.toml: #457
Can you submit a pull request?
Possibly
The text was updated successfully, but these errors were encountered: