From 4f6b4bf91c0dc9aefb99f2597dafc5fa39e75a17 Mon Sep 17 00:00:00 2001 From: Valentin Vago Date: Mon, 15 Jan 2018 20:05:53 +0100 Subject: [PATCH] allow passing default values to environment plugin --- packages/env/index.js | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/packages/env/index.js b/packages/env/index.js index 78d344f6e..13f92d2ad 100644 --- a/packages/env/index.js +++ b/packages/env/index.js @@ -1,5 +1,20 @@ const { EnvironmentPlugin } = require('webpack'); -module.exports = ({ config }, envs = []) => config - .plugin('env') - .use(EnvironmentPlugin, ['NODE_ENV', ...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); +};