![require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages](https://cdn.sanity.io/images/cgdhsj6q/production/be8ab80c8efa5907bc341c6fefe9aa20d239d890-1600x1097.png?w=400&fit=max&auto=format)
Security News
require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
consul-env-webpack-plugin
Advanced tools
A simple webpack plugin to parse consul KV to process.env.
A webpack plugin that convert the KV Store Endpoints in environment variables.
The KV Store Endpoints is a feature of consul.io.
Include the package locally in your repository.
npm install consul-env-webpack-plugin -D
yarn add consul-env-webpack-plugin -D
consul-env-webpack-plugin
wraps node-consul and Webpack.DefinePlugin
. As such, it takes the JSON
from the consul server
and parse the keys to process.env
with Webpack.DefinePlugin
.
The plugin can be installed with little configuration needed. Once installed, you can access the variables within your code using process.env
.
The example bellow shows a standard use-case
Configure the JSON in your consul server
{
"MY_API": "https://10.5.1.1"
}
Add it to your Webpack config file
// webpack.config.js
const ConsulPlugin = require('consul-env-webpack-plugin')
module.exports = {
...
plugins: [
new ConsulPlugin({
path: 'config/front/data', //path to keys
consul: {
... //node-consul options - see https://github.com/silas/node-consul
}
})
]
...
};
Use in your code
// provider.js
console.log(process.env.MY_API);
// 'https://10.5.1.1'
Use the following properties to configure your instance.
'config/front/data'
) - The path API to your data endpoints.options
) - This options are necessary to config your consul, see default options in node-consul.The following example shows how to set any/all arguments.
module.exports = {
...
plugins: [
new ConsulPlugin({
path: 'config/front/data',
consul: null //load the default options of node-consul
})
]
...
};
FAQs
A simple webpack plugin to parse consul KV to process.env.
We found that consul-env-webpack-plugin 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
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
Security News
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.