dotenv-webpack 1.5.4 → 1.5.5

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.
Files changed (3) hide show
  1. package/README.md +45 -20
  2. package/dist/index.js +20 -21
  3. package/package.json +22 -35
package/README.md CHANGED
@@ -1,17 +1,28 @@
1
- # dotenv-webpack
2
-
3
1
  A secure webpack plugin that supports dotenv and other environment variables and **only exposes what you choose and use**.
4
2
 
5
- ### Status
6
-
7
- [![npm](https://img.shields.io/npm/v/dotenv-webpack.svg?maxAge=0&style=flat)](https://www.npmjs.com/package/dotenv-webpack)
8
- [![Travis](https://travis-ci.org/mrsteele/dotenv-webpack.svg?branch=master)](https://travis-ci.org/mrsteele/dotenv-webpack)
9
- [![codecov](https://codecov.io/gh/mrsteele/dotenv-webpack/branch/master/graph/badge.svg)](https://codecov.io/gh/mrsteele/dotenv-webpack)
10
- [![Dependency Status](https://david-dm.org/mrsteele/dotenv-webpack.svg)](https://david-dm.org/mrsteele/dotenv-webpack)
11
- [![devDependency Status](https://david-dm.org/mrsteele/dotenv-webpack/dev-status.svg)](https://david-dm.org/mrsteele/dotenv-webpack?type=dev)
12
- [![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg)](http://standardjs.com/)
13
- [![npm](https://img.shields.io/npm/l/dotenv-webpack.svg?maxAge=0&style=flat)](https://raw.githubusercontent.com/mrsteele/dotenv-webpack/master/LICENSE)
14
- [![pull requests](https://img.shields.io/badge/pull%20requests-accepting-brightgreen.svg?style=flat)](https://github.com/mrsteele/dotenv-webpack/fork)
3
+ <div align="center">
4
+ <a href="https://www.npmjs.com/package/dotenv-webpack" target="_blank">
5
+ <img alt="npm" src="https://img.shields.io/npm/v/dotenv-webpack.svg?maxAge=0&style=flat" />
6
+ </a>
7
+ <a href="https://travis-ci.org/mrsteele/dotenv-webpack" target="_blank">
8
+ <img alt="Travis" src="https://travis-ci.org/mrsteele/dotenv-webpack.svg?branch=master" />
9
+ </a>
10
+ <a href="https://codecov.io/gh/mrsteele/dotenv-webpack" target="_blank">
11
+ <img alt="codecov" src="https://codecov.io/gh/mrsteele/dotenv-webpack/branch/master/graph/badge.svg" />
12
+ </a>
13
+ <a href="https://david-dm.org/mrsteele/dotenv-webpack" target="_blank">
14
+ <img alt="Dependency Status" src="https://david-dm.org/mrsteele/dotenv-webpack.svg" />
15
+ </a>
16
+ <a href="https://david-dm.org/mrsteele/dotenv-webpack?type=dev" target="_blank">
17
+ <img alt="devDependency Status" src="https://david-dm.org/mrsteele/dotenv-webpack/dev-status.svg" />
18
+ </a>
19
+
20
+ <h1>
21
+ <img width="30" heigth="30" src="https://raw.githubusercontent.com/motdotla/dotenv/master/dotenv.png" alt="dotenv" />
22
+ <img width="30" heigth="30" src="https://webpack.js.org/assets/icon-square-big.svg" alt="webpack">
23
+ dotenv-webpack
24
+ </h1>
25
+ </div>
15
26
 
16
27
  ### Installation
17
28
 
@@ -21,9 +32,9 @@ Include the package locally in your repository.
21
32
 
22
33
  ### Description
23
34
 
24
- `dotenv-webpack` wraps `dotenv` and `Webpack.DefinePlugin`. As such, it overwrites existing any existing `DefinePlugin` configurations. Also, like `DefinePlugin`, it does a text replace in the resulting bundle for any instances of `process.env`.
35
+ `dotenv-webpack` wraps `dotenv` and `Webpack.DefinePlugin`. As such, it does a text replace in the resulting bundle for any instances of `process.env`.
25
36
 
26
- Your `.env` files can include sensitive information. Because of this,`dotenv-webpack` will only expose environment variables that are **explicily referenced in your code** to your final bundle.
37
+ Your `.env` files can include sensitive information. Because of this,`dotenv-webpack` will only expose environment variables that are **explicitly referenced in your code** to your final bundle.
27
38
 
28
39
  ### Usage
29
40
 
@@ -48,10 +59,7 @@ const Dotenv = require('dotenv-webpack');
48
59
  module.exports = {
49
60
  ...
50
61
  plugins: [
51
- new Dotenv({
52
- path: './.env', // Path to .env file (this is the default)
53
- safe: true // load .env.example (defaults to "false" which does not use dotenv-safe)
54
- })
62
+ new Dotenv()
55
63
  ]
56
64
  ...
57
65
  };
@@ -59,14 +67,14 @@ module.exports = {
59
67
 
60
68
  ###### Use in your code
61
69
 
62
- ```
70
+ ```javascript
63
71
  // file1.js
64
72
  console.log(process.env.DB_HOST);
65
73
  // '127.0.0.1'
66
74
  ```
67
75
 
68
76
  ###### Resulting bundle
69
- ```
77
+ ```javascript
70
78
  // bundle.js
71
79
  console.log('127.0.0.1');
72
80
  ```
@@ -90,6 +98,23 @@ Use the following properties to configure your instance.
90
98
  * **systemvars** (`false`) - Set to true if you would rather load all system variables as well (useful for CI purposes).
91
99
  * **silent** (`false`) - If true, all warnings will be surpressed.
92
100
 
101
+ The following example shows how to set any/all arguments.
102
+
103
+ ```javascript
104
+ module.exports = {
105
+ ...
106
+ plugins: [
107
+ new Dotenv({
108
+ path: './some.other.env', // load this now instead of the ones in '.env'
109
+ safe: true, // load '.env.example' to verify the '.env' variables are all set. Can also be a string to a different file.
110
+ systemvars: true, // load all the predefined 'process.env' variables which will trump anything local per dotenv specs.
111
+ silent: true // hide any errors
112
+ })
113
+ ]
114
+ ...
115
+ };
116
+ ```
117
+
93
118
  ### LICENSE
94
119
 
95
120
  MIT
package/dist/index.js CHANGED
@@ -4,8 +4,6 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
 
7
- var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
8
-
9
7
  var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
10
8
 
11
9
  var _dotenv = require('dotenv');
@@ -32,45 +30,46 @@ var Dotenv = function () {
32
30
  * @param {Bool} [options.silent=false] - If true, suppress warnings, if false, display warnings.
33
31
  * @returns {webpack.DefinePlugin}
34
32
  */
35
- function Dotenv(options) {
36
- _classCallCheck(this, Dotenv);
33
+ function Dotenv() {
34
+ var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
35
+ _ref$path = _ref.path,
36
+ path = _ref$path === undefined ? './.env' : _ref$path,
37
+ safe = _ref.safe,
38
+ systemvars = _ref.systemvars,
39
+ silent = _ref.silent,
40
+ sample = _ref.sample;
37
41
 
38
- options = _extends({
39
- path: './.env',
40
- safe: false,
41
- systemvars: false,
42
- silent: false
43
- }, options);
42
+ _classCallCheck(this, Dotenv);
44
43
 
45
44
  // Catch older packages, but hold their hand (just for a bit)
46
- if (options.sample) {
47
- if (options.safe) {
48
- options.safe = options.sample;
45
+ if (sample) {
46
+ if (safe) {
47
+ safe = sample;
49
48
  }
50
- this.warn('dotenv-webpack: "options.sample" is a deprecated property. Please update your configuration to use "options.safe" instead.', options.silent);
49
+ this.warn('dotenv-webpack: "options.sample" is a deprecated property. Please update your configuration to use "options.safe" instead.', silent);
51
50
  }
52
51
 
53
52
  var vars = {};
54
- if (options.systemvars) {
53
+ if (systemvars) {
55
54
  Object.keys(process.env).map(function (key) {
56
55
  vars[key] = process.env[key];
57
56
  });
58
57
  }
59
58
 
60
- var env = this.loadFile(options.path, options.silent);
59
+ var env = this.loadFile(path, silent);
61
60
 
62
61
  var blueprint = env;
63
- if (options.safe) {
62
+ if (safe) {
64
63
  var file = './.env.example';
65
- if (options.safe !== true) {
66
- file = options.safe;
64
+ if (safe !== true) {
65
+ file = safe;
67
66
  }
68
- blueprint = this.loadFile(file, options.silent);
67
+ blueprint = this.loadFile(file, silent);
69
68
  }
70
69
 
71
70
  Object.keys(blueprint).map(function (key) {
72
71
  var value = vars.hasOwnProperty(key) ? vars[key] : env[key];
73
- if (!value && options.safe) {
72
+ if (!value && safe) {
74
73
  throw new Error('Missing environment variable: ' + key);
75
74
  } else {
76
75
  vars[key] = value;
package/package.json CHANGED
@@ -1,11 +1,12 @@
1
1
  {
2
2
  "name": "dotenv-webpack",
3
3
  "description": "A simple webpack plugin to support dotenv.",
4
- "version": "1.5.4",
4
+ "version": "1.5.5",
5
5
  "main": "index.js",
6
6
  "scripts": {
7
+ "precommit": "npm run lint",
8
+ "prepush": "npm t",
7
9
  "lint": "standard",
8
- "validate-commit": "validate-commit-msg",
9
10
  "predoc": "rimraf docs",
10
11
  "doc": "esdoc -c config/doc.json",
11
12
  "pretest": "npm run build",
@@ -13,8 +14,7 @@
13
14
  "posttest": "nyc report --reporter=lcov",
14
15
  "prebuild": "rimraf dist",
15
16
  "build": "babel --copy-files --out-dir dist src",
16
- "travis": "npm run lint && npm t",
17
- "semantic-release": "semantic-release pre && npm publish && semantic-release post"
17
+ "travis": "npm run lint && npm t"
18
18
  },
19
19
  "repository": {
20
20
  "type": "git",
@@ -39,50 +39,37 @@
39
39
  },
40
40
  "homepage": "https://github.com/mrsteele/dotenv-webpack#readme",
41
41
  "peerDependencies": {
42
- "webpack": "^1 || ^2 || ^3"
42
+ "webpack": "^1 || ^2 || ^3 || ^4"
43
43
  },
44
44
  "dependencies": {
45
- "dotenv": "^4.0.0"
45
+ "dotenv": "^5.0.1"
46
46
  },
47
47
  "devDependencies": {
48
- "babel-cli": "^6.24.1",
49
- "babel-eslint": "^7.2.3",
48
+ "babel-cli": "^6.26.0",
49
+ "babel-eslint": "^8.2.2",
50
50
  "babel-plugin-transform-object-assign": "^6.22.0",
51
- "babel-preset-es2015": "^6.24.1",
52
- "babel-register": "^6.24.1",
53
- "chai": "^4.0.0",
54
- "esdoc": "^0.5.2",
55
- "ghooks": "^2.0.0",
56
- "mocha": "^3.4.1",
57
- "nyc": "^11.0.3",
58
- "rimraf": "^2.6.1",
59
- "semantic-release": "^6.3.6",
60
- "sinon": "^2.3.2",
61
- "standard": "^10.0.2",
62
- "validate-commit-msg": "^2.12.1",
63
- "webpack": "^3.1.0"
51
+ "babel-preset-env": "^1.6.1",
52
+ "babel-register": "^6.26.0",
53
+ "chai": "^4.1.2",
54
+ "esdoc": "^1.0.4",
55
+ "husky": "^0.14.3",
56
+ "mocha": "^5.0.1",
57
+ "nyc": "^11.3.0",
58
+ "rimraf": "^2.6.2",
59
+ "sinon": "^4.4.2",
60
+ "standard": "^11.0.0",
61
+ "webpack": "^3.10.0"
64
62
  },
65
63
  "files": [
66
- "dist",
67
- "LICENSE",
68
- "README.md"
64
+ "dist"
69
65
  ],
70
66
  "standard": {
71
67
  "parser": "babel-eslint"
72
68
  },
73
- "config": {
74
- "ghooks": {
75
- "pre-commit": "npm run lint",
76
- "commit-msg": "npm run validate-commit",
77
- "pre-push": "npm t",
78
- "post-merge": "npm install && npm prune",
79
- "post-rewrite": "npm install && npm prune"
80
- }
81
- },
82
69
  "browser": "browser.js",
83
70
  "babel": {
84
71
  "presets": [
85
- "es2015"
72
+ "env"
86
73
  ],
87
74
  "plugins": [
88
75
  "transform-object-assign"
@@ -94,4 +81,4 @@
94
81
  "dist/**/*.js"
95
82
  ]
96
83
  }
97
- }
84
+ }