-
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
Environment variables from the context.production
toml config are being injected during netlify dev
#1873
Comments
context.production
toml config are being injected during netlify dev
I'm seeing this same issue. Here's what I can see based on the following configuration. netlify.toml[build]
command = "npm run build"
publish = "./dist/apps/web-ui"
[[redirects]]
from = "/v1/graphql"
to = "https://my-graphqlserver.com/v1/graphql/"
force = false
status = 200
[dev]
# command="npm run start"
# targetPort=4200
# framework="#custom"
[context.local.environment]
NX_GRAPH_PROXY_URL="http://localhost:8080/v1/graphql"
NX_ENABLE_PROXY="true"
NX_GRAPH_WEBSOCKET_URL="ws://localhost:8080/v1/graphql" Listing VariablesThe current solution is on the command: Output > Initial build environment
cwd: C:\Users\dev\source\repo\netlify-support-poc\my-workspace
mode: cli
siteId: c176d949-e6b2-4f4c-1123-1ca47f34c02f
> UI build settings
baseRelDir: true
build:
command: npm run build
publish: dist/apps/web-ui
> Resolved build environment
branch: master
buildDir: C:\Users\dev\source\repo\netlify-support-poc\my-workspace
configPath: C:\Users\dev\source\repo\netlify-support-poc\my-workspace\netlify.toml
context: production Setting CONTEXTcommand: Output > Initial build environment
cwd: C:\Users\dev\source\repo\netlify-support-poc\my-workspace
mode: cli
siteId: c176d949-e6b2-4f4c-1123-1ca47f34c02f
> UI build settings
baseRelDir: true
build:
command: npm run build
publish: dist/apps/web-ui
> Resolved build environment
branch: master
buildDir: C:\Users\dev\source\repo\netlify-support-poc\my-workspace
configPath: C:\Users\dev\source\repo\netlify-support-poc\my-workspace\netlify.toml
context: local
.... REMOVED
.----------------------------------------------------------------------------.
| Environment variables |
|----------------------------------------------------------------------------|
| Key | Value |
|-------------------------|--------------------------------------------------|
| NX_GRAPH_PROXY_URL | http://localhost:8080/v1/graphql |
| NX_ENABLE_PROXY | true |
| NX_GRAPH_WEBSOCKET_URL | ws://localhost:8080/v1/graphql |
'----------------------------------------------------------------------------' However, running the site in the same context ( I've manually adding some code ( if (!existsInProcess) {
// Omitting `general` env vars to reduce noise in the logs.
if (usedSource !== 'general') {
log(`${NETLIFYDEVLOG} Injected ${usedSourceName} env var: ${chalk.yellow(key)} with value: ${chalk.red(variable.value)}`)
}
process.env[key] = variable.value
} The output of that statement shows the expected values:
As stated above, it loads the server without the dev values. Other Comments
$ CONTEXT=local npm run netlify -- -v && npm run netlify -- dev --debug
> [email protected] netlify C:\Users\aaron\source\repo\netlify-support-poc\my-workspace
> netlify "-v"
netlify-cli/3.0.0 win32-x64 node-v12.20.0 |
Hi @anAgent and @askrzypczak. This is due to a recent change we made in how the CLI resolves |
A fix for this issue has been published in version |
I have a related issue in I set The issue I have is that |
Hi @lloydh, this should work: [build.environment]
NODE_ENV = "production"
[context.dev.environment]
NODE_ENV = "dev" If that doesn't work, please open a new issue and follow the issue template. |
Describe the bug
My environment variables from the
context.production
toml config are being injected during netlify devConfiguration
in my main.js i have the following:
console.debug("deploy mode: ", process.env.GRIDSOME_DEPLOY_MODE)
(some background: gridsome includes any env var which is prefixed by 'GRIDSOME" in the client env, which is why you can console.log it)
the output is
deploy mode: production
Additionally, the webpack config files that I am using are listening to NODE_ENV and are packing for production instead of dev.I used the CLI
no flags, just
netlify dev
I just updated from
[email protected]
to[email protected]
.Before the update the
GRIDSOME_DEPLOY_MODE
var was always undefined if you did not have it set in a.env
(thebuild.environment
was being ignored which was OK with me)I have been wracking my brain looking for a way to force the env var to 'development' and all I have right now is to set it in a
.env
file but this is REALLY not something that I want to do, as it means using an affirmative action to force a default behavior: i.e. anyone that clones the repo and doesnt configure their gitignored.env
file with the deploy mode set will accidentally run in prod mode. it should fail into 'undefined' instead of 'context.production.environment' from the toml.I tried using
[dev.environment]
in the toml but it seems to just be ignored, which is not surprising to me since there is no documentation that I could find saying thatdev.environment
is a validdev
configBackground at netlify/build#792
The text was updated successfully, but these errors were encountered: