Security News
GitHub Removes Malicious Pull Requests Targeting Open Source Repositories
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
rollup-plugin-dotenv
Advanced tools
Rollup plugin that loads available .env files and replaces the defined variables with their values
npm install rollup-plugin-dotenv
Create a rollup.config.js
configuration file and import the plugin:
import dotenv from "rollup-plugin-dotenv"
export default {
input: "src/index.js",
output: [
dir: "dist/build"
],
plugins: [
dotenv()
]
}
create your .env
file in the root of your project.
# .env
FOO=bar
so you can use FOO in your javascript files.
// src/index.js
console.log(process.env.FOO)
your env variables will be replaced by their values in your bundled file.
// dist/build/index.js
console.log('bar')
if you want to know more about the principle and restrictions of replacement, please read @rollup/plugin-replace notes.
You can specify the options below.
cwd
Type: String
Default: "."
directory in which to search for env files.
envKey
Type: String
Default: "NODE_ENV"
key used to search for .env files by node environment
Rollup will merge env vars located at
[
`.env.${process.env[envKey]}.local`,
`.env.${process.env[envKey]}`,
'.env.local',
'.env',
]
so if you are in prod
, rollup will search in
['.env.prod.local', '.env.prod', '.env.local', '.env']
and merge the result.
FAQs
Rollup plugin that loads available .env files and replaces the defined variables with their values
The npm package rollup-plugin-dotenv receives a total of 1,762 weekly downloads. As such, rollup-plugin-dotenv popularity was classified as popular.
We found that rollup-plugin-dotenv demonstrated a healthy version release cadence and project activity because the last version was released less than 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
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.