Comments (3)
Hi! Thank you for the suggestion. Why do you think one file is better than two (.develop and .production)? I followed gatsby doc for best practices: https://www.gatsbyjs.org/docs/environment-variables/#client-side-javascript
I didn't commit these files because they are in the gitignore and I wanted to avoid that people will fork the project and they will commit their secrets in the repository
from gatsby-firebase-simple-auth.
Okay, I read the docs. So, did I need to add NODE_ENV
variable to production
, test
, or staging
if I want to just one .env
file?
from gatsby-firebase-simple-auth.
In the gatsby-config.js you can see:
require("dotenv").config({
path: `.env.${process.env.NODE_ENV}`,
})
And it works in this way with more .env
files:
By default gatsby supports only 2 environments:
If you run gatsby develop, then you will be in the ‘development’ environment.
If you run gatsby build or gatsby serve, then you will be in the ‘production’ environment.
I don't know if it's possible use only a .env
file, maybe you can change gatsby-config in this way:
require("dotenv").config({
path: `.env`,
})
If you want add more custom environment (for example ".env.staging") you can't override NODE_ENV variable but you have to use another variable: https://www.gatsbyjs.org/docs/environment-variables/#additional-environments-staging-test-etc
const activeEnv =
process.env.GATSBY_ACTIVE_ENV || process.env.NODE_ENV || "development"
require("dotenv").config({
path: `.env.${activeEnv}`,
})
and build in this way from shell: GATSBY_ACTIVE_ENV=staging npm run develop
I understand you think one file is better, but this way is not bad too :)
from gatsby-firebase-simple-auth.
Related Issues (7)
- Can't sign with Google in the demo HOT 5
- Back functionality doesn't work after clicking Profile HOT 1
- Apple login example HOT 1
- Add .env.sample + firebase steps required for smoother Dev experience HOT 1
- Trouble with gatsby-plugin-firebase v0.2 HOT 1
- Can't seem to get this to run it's saying there is a issue with Can't resolve 'gatsby-react-router-scroll'
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gatsby-firebase-simple-auth.