Skip to content
This repository has been archived by the owner on Sep 12, 2019. It is now read-only.

Set site environment variables in local dev #5

Merged
merged 2 commits into from
Mar 8, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion src/commands/dev/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,21 @@ class DevCommand extends Command {
addon.slug
}`
for (const key in addon.env) {
process.env[key] = addon.env[key]
process.env[key] = process.env[key] || addon.env[key]
}
})
const api = this.netlify.api
const apiSite = await api.getSite({site_id: site.id})
// TODO: We should move the environment outside of build settings and possibly have a
// `/api/v1/sites/:site_id/environment` endpoint for it that we can also gate access to
// In the future and that we could make context dependend
if (apiSite.build_settings && apiSite.build_settings.env) {
for (const key in apiSite.build_settings.env) {
process.env[key] = process.env[key] || apiSite.build_settings.env[key]
}
}
}
process.env.NETLIFY_DEV = 'true'
let settings = serverSettings()
if (!(settings && settings.cmd)) {
this.log('No dev server detected, using simple static server')
Expand Down