dotenv-webpack 7.1.1 → 8.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
  <img width="30" height="30" src="https://webpack.js.org/assets/icon-square-big.svg" alt="webpack">
4
4
  dotenv-webpack
5
5
  </h1>
6
-
6
+
7
7
  A secure webpack plugin that supports dotenv and other environment variables and **only exposes what you choose and use**.
8
8
 
9
9
  <div align="center">
@@ -16,6 +16,8 @@ A secure webpack plugin that supports dotenv and other environment variables and
16
16
  <a href="https://github.com/mrsteele/dotenv-webpack/actions/workflows/main.yml" target="_blank">
17
17
  <img alt="Main" src="https://github.com/mrsteele/dotenv-webpack/actions/workflows/main.yml/badge.svg" />
18
18
  </a>
19
+ <img alt="Vulnerabilities Score" src="https://snyk-widget.herokuapp.com/badge/npm/dotenv-webpack/badge.svg" />
20
+ <img alt="Known Vulnerabilities" src="https://snyk.io/test/github/mrsteele/dotenv-webpack/badge.svg" />
19
21
  <object id="badge" data="https://snyk-widget.herokuapp.com/badge/npm/dotenv-webpack/badge.svg" type="image/svg+xml"></object>
20
22
  <a href="https://www.dotenv.org/get-started?r=3" target="_blank">
21
23
  <img alt="dotenv-vault" src="https://badge.dotenv.org/works-with.svg?r=3" />
@@ -107,7 +109,7 @@ If you are running into issues where you or another package you use interfaces w
107
109
 
108
110
  Use the following properties to configure your instance.
109
111
 
110
- * **path** (`'./.env'`) - The path to your environment variables.
112
+ * **path** (`'./.env'`) - The path to your environment variables. This same path applies to the `.env.example` and `.env.defaults` files. [Read more here](#about-path-settings).
111
113
  * **safe** (`false`) - If true, load '.env.example' to verify the '.env' variables are all set. Can also be a string to a different file.
112
114
  * **allowEmptyValues** (`false`) - Whether to allow empty strings in safe mode. If false, will throw an error if any env variables are empty (but only if safe mode is enabled).
113
115
  * **systemvars** (`false`) - Set to true if you would rather load all system variables as well (useful for CI purposes).
@@ -136,6 +138,51 @@ module.exports = {
136
138
  ...
137
139
  };
138
140
  ```
141
+ ## About `path` settings
142
+
143
+ As previously mentioned, it is possible to customize the `path` where the `.env` file is located as well as its *filename* from the plugin settings:
144
+
145
+ ```javascript
146
+ module.exports = {
147
+ ...
148
+ plugins: [
149
+ new Dotenv({
150
+ path: './some.other.env',
151
+ })
152
+ ]
153
+ ...
154
+ };
155
+ ```
156
+
157
+ It is important to mention that this same path and filename will be used for the location of the `.env.example` and `.env.defaults` files if they are configured, this will only add the `.example` and `.defaults` suffixes respectively:
158
+
159
+ ```javascript
160
+ module.exports = {
161
+ ...
162
+ plugins: [
163
+ new Dotenv({
164
+ path: '../../path/to/other.env',
165
+ safe: true, // load '../../path/to/other.env.example'
166
+ defaults: true, // load '../../path/to/other.env.defaults'
167
+ })
168
+ ]
169
+ ...
170
+ };
171
+ ```
172
+
173
+ This is especially useful when working with [Monorepos](https://monorepo.tools/) where the same configuration can be shared within all sub-packages of the repository:
174
+
175
+ ```bash
176
+ .
177
+ ├── packages/
178
+ │ ├── app/
179
+ │ │ └── webpack.config.js # { path: '../../.env' }
180
+ │ └── libs/
181
+ │ └── webpack.config.js # { path: '../../.env' }
182
+ ├── .env
183
+ ├── .env.example
184
+ └── .env.defaults
185
+ ```
139
186
 
140
187
  ## LICENSE
141
188
 
package/dist/index.js CHANGED
@@ -126,7 +126,7 @@ var Dotenv = /*#__PURE__*/function () {
126
126
  var blueprint = env;
127
127
 
128
128
  if (safe) {
129
- var file = './.env.example';
129
+ var file = "".concat(path, ".example");
130
130
 
131
131
  if (safe !== true) {
132
132
  file = safe;
@@ -147,12 +147,13 @@ var Dotenv = /*#__PURE__*/function () {
147
147
  key: "getDefaults",
148
148
  value: function getDefaults() {
149
149
  var _this$config3 = this.config,
150
+ path = _this$config3.path,
150
151
  silent = _this$config3.silent,
151
152
  defaults = _this$config3.defaults;
152
153
 
153
154
  if (defaults) {
154
155
  return this.loadFile({
155
- file: defaults === true ? './.env.defaults' : defaults,
156
+ file: defaults === true ? "".concat(path, ".defaults") : defaults,
156
157
  silent: silent
157
158
  });
158
159
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "dotenv-webpack",
3
3
  "description": "A simple webpack plugin to support dotenv.",
4
- "version": "7.1.1",
4
+ "version": "8.0.0",
5
5
  "main": "index.js",
6
6
  "scripts": {
7
7
  "precommit": "npm run lint",