Skip to content
This repository has been archived by the owner on Feb 18, 2024. It is now read-only.

Commit

Permalink
refactor changes to allow default values
Browse files Browse the repository at this point in the history
  • Loading branch information
zeropaper committed Jan 13, 2018
1 parent 640c837 commit 57fed5f
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions packages/env/index.js
Original file line number Diff line number Diff line change
@@ -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);
};

0 comments on commit 57fed5f

Please sign in to comment.