From 57fed5fbb021bd6b369ca3b627c0c62cbd589330 Mon Sep 17 00:00:00 2001 From: Valentin Vago Date: Sat, 13 Jan 2018 13:28:11 +0100 Subject: [PATCH] refactor changes to allow default values --- packages/env/index.js | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/packages/env/index.js b/packages/env/index.js index 4df46a48e..13f92d2ad 100644 --- a/packages/env/index.js +++ b/packages/env/index.js @@ -1,7 +1,20 @@ const { EnvironmentPlugin } = require('webpack'); -module.exports = ({ config }, envs = []) => config - .plugin('env') - .use(EnvironmentPlugin, Array.isArray(envs) ? - ['NODE_ENV', ...envs] : - [{ NODE_ENV: 'development', ...envs }]); +module.exports = ({ config }, envs = []) => { + let pluginOptions; + + if (Array.isArray(envs)) { + pluginOptions = ['NODE_ENV', ...envs]; + } + else { + pluginOptions = [ + Object.assign({ + NODE_ENV: 'development' + }, envs) + ]; + } + + config + .plugin('env') + .use(EnvironmentPlugin, pluginOptions); +};