webpack-config-utils
Advanced tools
Comparing version 2.2.0 to 2.3.0
@@ -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 }; } |
@@ -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; | ||
} |
{ | ||
"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", |
@@ -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({ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
103343
31
1651