Setup webpack config with additional env property like babel preset options.
$ npm install webpack-setup-env
// webpack.config.js
const path = require('path');
const webpack = require('webpack');
const webpackSetup = require('webpack-setup-env');
module.exports = webpackSetup({
output: {
path: path.resolve(__dirname, 'dist'),
publicPath: '/'
},
module: {...},
plugins: [new webpack.DefinePlugin({...})],
resolve: {...},
env: {
development: {
mode: 'development',
devtool: 'inline-source-map',
entry: [
'webpack-hot-middleware/client',
path.resolve(__dirname, 'src/app.js')
],
output: {
filename: 'js/app.bundle.js'
},
plugins: [...]
},
production: {
mode: 'production',
entry: [
path.resolve(__dirname, 'src/app.js')
],
output: {
filename: 'js/app.[hash].bundle.js'
},
plugins: [ ... ]
},
...
}
});
- Params:
-
options
:<object>
- Webpack configuration.-
options.env[process.env.NODE_ENV]
- Webpack configuration
-
-
- Returns:
<object>
- Merged bylodash.mergeWith
- BabelJS API, like creating a preset.
MIT © Guntur Poetra