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

allow passing default values to environment plugin #657

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 18 additions & 3 deletions packages/env/index.js
Original file line number Diff line number Diff line change
@@ -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 = [
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ftes i think it should be backward compatible (and my PR reflects it: 4f6b4bf).

Your PR is slightly different because it wraps the object inside an array.

I think this is what @eliperelman meant with

Unfortunately the else clause will violate that.

Object.assign({
NODE_ENV: 'development'
}, envs)
];
}

config
.plugin('env')
.use(EnvironmentPlugin, pluginOptions);
};