Security News
Bun 1.2 Released with 90% Node.js Compatibility and Built-in S3 Object Support
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.
babel-plugin-replace-config-vars
Advanced tools
npm install --save-dev babel-plugin-replace-config-vars
In .babelrc
add your configuration options:
// ...
"plugins": [
"replace-config-vars"
],
"extra": {
"config": [
"./config/$ENV.js",
"./config/$ENV.json",
{
"development": {
"URL": "http://localhost:3000"
}
}
]
}
The "config" keyword is expected to include an array of configuration. Each
entry in the array can be either a string
or an object
.
If the entry is a string
, it is expected to be a path to a file. The file can
either be a JSON file or a javascript file. Replace config vars respects either and simply
does a require
. If you use a .js
file, make sure you use module.exports
on the file
to actually export the variables. See test/config/test.js
for an example.
If the string contains a $ENV
, it will be replaced with the current environment
set by NODE_ENV
. That is, if your process is started like so:
NODE_ENV=test npm run
The above configuration would change the first two entries into test
resulting in the
files at ./config/test.js
and ./config/test.json
to be loaded.
If the entry is an object
and it contains a key of the current environment (see above for
example), then it will simply use the hardcoded values.
In the source, we can simply reference the variables in our config by prepending them
with the normal node process.env.
. For instance, to reference the URL
option
in the config above, assuming our process is running with NODE_ENV=development
,
then we can use the variable process.env.URL
in our source and babel will
replace it when it processes it.
var url = process.env.URL;
// ...
FAQs
Replace strings with their config variables
The npm package babel-plugin-replace-config-vars receives a total of 15 weekly downloads. As such, babel-plugin-replace-config-vars popularity was classified as not popular.
We found that babel-plugin-replace-config-vars 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
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.
Security News
Biden's executive order pushes for AI-driven cybersecurity, software supply chain transparency, and stronger protections for federal and open source systems.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.