-
Notifications
You must be signed in to change notification settings - Fork 0
Configure Environment
Stupid edited this page Mar 29, 2020
·
8 revisions
Just configure in your ~/.zshrc or ~/.bashrc:
# .zshrc
# HYPE env variables start
export NX_CONTENTFUL_PROD_DELIVERY_ACCESS_TOKEN=<delivery_access_token>
export NX_CONTENTFUL_PROD_PREVIEW_ACCESS_TOKEN=<preview_access_token>
# HYPE env variables end
Since we're using nx to manage our repo, it provides an environments folder under each app, like lucas.
-
environments/index.tsentry file, it loadsenvironment.tsandenvironment.local.tsin development mode and will be replaced byenvironment.prod.tsin production mode -
environments/environment.tsdefault environment for development -
environments/environment.prod.tsdefault environment for production -
environments/environment.local.tsthis is a special file that is not staged, you can create one in local by copying the content ofenvironments/environment.ts
For sensitive information, we use env variables like NX_CONTENTFUL_PROD_DELIVERY_ACCESS_TOKEN in the file
export const environment = {
production: false,
contentful: {
host: '//cdn.contentful.com',
accessToken: process.env.NX_CONTENTFUL_PROD_DELIVERY_ACCESS_TOKEN,
space: 'mbwqgs5je33j',
},
};
We use the fileReplacement feature of nx to replace the env file with another in production env. E.g. you can find the configuration for lucas in workspace.json
