webpack-config-utils
Advanced tools
+0
-12
@@ -52,14 +52,2 @@ 'use strict'; | ||
| var _removeEmptyProperties = require('./remove-empty-properties'); | ||
| Object.keys(_removeEmptyProperties).forEach(function (key) { | ||
| if (key === "default" || key === "__esModule") return; | ||
| Object.defineProperty(exports, key, { | ||
| enumerable: true, | ||
| get: function get() { | ||
| return _removeEmptyProperties[key]; | ||
| } | ||
| }); | ||
| }); | ||
| function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } |
+25
-8
@@ -9,8 +9,13 @@ 'use strict'; | ||
| /** | ||
| * Accepts an array and removes all undefined values (using `filter`) | ||
| * Accepts an array or an object. In the case of an array, remove all undefined values (using `filter`). | ||
| * In the case of an object, remove all keys whose values are undefined. | ||
| * | ||
| * @example | ||
| * // Primary use case is in `plugins` where `undefined` values can cause issues | ||
| * // Primary use case is in `plugins` and `entry` where `undefined` values can cause issues | ||
| * module.exports = { | ||
| * ... your config | ||
| * entry: removeEmptyProperties({ | ||
| * app: ifProd('./indexWithoutCSS', './indexWithCSS'), | ||
| * css: ifNotProd('./style.css') | ||
| * }), | ||
| * plugins: removeEmpty([ | ||
@@ -41,10 +46,22 @@ * ifProduction(new webpack.optimize.DedupePlugin()), | ||
| * | ||
| * @param {Array} array The array to remove undefined values from | ||
| * @return {Array} The resulting array | ||
| * @param {object | Array} input The object to remove keys from or the array to remove values from | ||
| * @returns {object | Array} The resulting object or array. | ||
| */ | ||
| function removeEmpty(array) { | ||
| return array.filter(function (item) { | ||
| return typeof item !== 'undefined'; | ||
| }); | ||
| function removeEmpty(input) { | ||
| var output = void 0; | ||
| if (Array.isArray(input)) { | ||
| output = input.filter(function (item) { | ||
| return typeof item !== 'undefined'; | ||
| }); | ||
| } else { | ||
| output = {}; | ||
| Object.keys(input).forEach(function (key) { | ||
| var value = input[key]; | ||
| if (typeof value !== 'undefined') { | ||
| output[key] = value; | ||
| } | ||
| }); | ||
| } | ||
| return output; | ||
| } |
+1
-1
| { | ||
| "name": "webpack-config-utils", | ||
| "version": "2.2.0", | ||
| "version": "2.3.0", | ||
| "description": "Utilities to help your webpack config be easier to read", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
+3
-3
@@ -51,3 +51,3 @@ # webpack-config-utils | ||
| const webpack = require('webpack') | ||
| const {getIfUtils, removeEmpty, removeEmptyProperties} = require('webpack-config-utils') | ||
| const {getIfUtils, removeEmpty} = require('webpack-config-utils') | ||
@@ -58,3 +58,3 @@ const {ifProduction} = getIfUtils(process.env.NODE_ENV) | ||
| // ... your config | ||
| entry: removeEmptyProperties({ | ||
| entry: removeEmpty({ | ||
| app: ifProd('./indexWithoutCSS', './indexWithCSS'), | ||
@@ -65,3 +65,3 @@ css: ifProd('./style.scss') | ||
| loaders: [ | ||
| removeEmptyProperties({ | ||
| removeEmpty({ | ||
| test: /\.scss$/, | ||
@@ -68,0 +68,0 @@ loader: ifProd(ExtractTextPlugin.extract({ |
| 'use strict'; | ||
| Object.defineProperty(exports, "__esModule", { | ||
| value: true | ||
| }); | ||
| exports.removeEmptyProperties = removeEmptyProperties; | ||
| /** | ||
| * Accepts an object and removes all keys whose values are undefined. | ||
| * @example | ||
| * // Use case: move CSS into separate file for production (with `extract-text-webpack-plugin`) | ||
| * // but not in development: | ||
| * { | ||
| * // other webpack configs | ||
| * entry: removeEmptyProperties({ | ||
| * app: ifProd('./indexWithoutCSS', './indexWithCSS'), | ||
| * css: ifNotProd('./style.css') | ||
| * }) | ||
| * { | ||
| * @param {object} object The object to remove keys from | ||
| * @returns {object} The resulting object | ||
| */ | ||
| function removeEmptyProperties(object) { | ||
| var output = {}; | ||
| Object.keys(object).forEach(function (key) { | ||
| var value = object[key]; | ||
| if (typeof value !== 'undefined') { | ||
| output[key] = value; | ||
| } | ||
| }); | ||
| return output; | ||
| } |
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 2 instances in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 2 instances in 1 package
103343
-0.62%31
-3.12%1651
-1.32%