webpack/webpack — pull request #571 by sb (2014-11-05 10:31:05+00:00)
Title: Added EnvPlugin.

This adds a convenience plugin that uses `DefinePlugin` to defining environment variables from `process.env`. It also warns if you've forgotten to define a variable.

Example:

**app.js**
```javascript
if (process.env.NODE_ENV === 'production') {
// Do something only in production mode
}
```

**webpack.config.js**
```javascript
var webpack = require('webpack')

module.exports = {
// ...

plugins: [
new webpack.EnvPlugin('NODE_ENV', 'API_URL')
]
}
```

This will output the following warning:
```
[EnvPlugin] Warning: API_URL environment variable is undefined.
```

And result in the following javascript output:

```javascript
if (('production') === 'production') {
// Do something only in production mode
}
```