Security News
The Unpaid Backbone of Open Source: Solo Maintainers Face Increasing Security Demands
Solo open source maintainers face burnout and security challenges, with 60% unpaid and 60% considering quitting.
gatsby-env-variables
Advanced tools
Webpack feature to provide your custom environment env in client side
Use BUILD_ENV
to chose current .env
file
$ npm i gatsby-env-variables
or
$ yarn add gatsby-env-variables
Add the plugin to your gatsby-config.js
.
module.exports = {
plugins: [
`gatsby-env-variables`
]
}
Create your's .env
files in root of your project
project/
│ package.json
│ .env.development
│ .env.staging
└ .env.production
.env.staging
HAS_HEADER=true
Run your yarn/npm script with BUILD_ENV
variable to chose your environment, default selected is development
package.json
BUILD_ENV=staging yarn start
Use in client-side
function Example() {
return process.env.HAS_HEADER && <Header />
}
envFolderPath
This options allows you to specify which folder will stay your .env
files
Example:
module.exports = {
plugins: [
{
resolve: `gatsby-env-variables`,
options: {
envFolderPath: "src/env/"
}
}
]
}
project/
├── src/
│ ├── env/
│ │ ├── .env.development
│ │ ├── .env.staging
│ │ └── .env.production
Check out the resolve section of the Webpack config documentation for more information.
FAQs
Use your env variables in client side
The npm package gatsby-env-variables receives a total of 2,522 weekly downloads. As such, gatsby-env-variables popularity was classified as popular.
We found that gatsby-env-variables demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Solo open source maintainers face burnout and security challenges, with 60% unpaid and 60% considering quitting.
Security News
License exceptions modify the terms of open source licenses, impacting how software can be used, modified, and distributed. Developers should be aware of the legal implications of these exceptions.
Security News
A developer is accusing Tencent of violating the GPL by modifying a Python utility and changing its license to BSD, highlighting the importance of copyleft compliance.