1 | ;
|
2 |
|
3 | Object.defineProperty(exports, "__esModule", {
|
4 | value: true
|
5 | });
|
6 | exports.removeEmpty = removeEmpty;
|
7 |
|
8 | /**
|
9 | * Accepts an array and removes all undefined values (using `filter`)
|
10 | *
|
11 | * @example
|
12 | * // Primary use case is in `plugins` where `undefined` values can cause issues
|
13 | * module.exports = {
|
14 | * ... your config
|
15 | * plugins: removeEmpty([
|
16 | * ifProduction(new webpack.optimize.DedupePlugin()),
|
17 | * ifProduction(new webpack.LoaderOptionsPlugin({
|
18 | * minimize: true,
|
19 | * quiet: true,
|
20 | * })),
|
21 | * ifProduction(new webpack.DefinePlugin({
|
22 | * 'process.env': {
|
23 | * NODE_ENV: '"production"',
|
24 | * },
|
25 | * })),
|
26 | * ifProduction(new webpack.optimize.UglifyJsPlugin({
|
27 | * compress: {
|
28 | * screw_ie8: true,
|
29 | * warnings: false,
|
30 | * },
|
31 | * })),
|
32 | * new HtmlWebpackPlugin({
|
33 | * template: './index.html',
|
34 | * inject: 'head',
|
35 | * }),
|
36 | * ifProduction(new OfflinePlugin()),
|
37 | * ]),
|
38 | * }
|
39 | *
|
40 | * @param {Array} array The array to remove undefined values from
|
41 | * @return {Array} The resulting array
|
42 | */
|
43 |
|
44 | function removeEmpty(array) {
|
45 | return array.filter(function (item) {
|
46 | return typeof item !== 'undefined';
|
47 | });
|
48 | } |
\ | No newline at end of file |