Extends webpack-merge to handle nested arrays and functions, recursively
This webpack.config.js
can configure itself based on already defined attributes. See publicPath for example, it's based on devtool been set or not and use devServer host and port to build the url.
module.exports = require('mergePlus')([
{
context: __dirname,
entry: './main.js',
output: {
filename: 'index.js'
},
devServer: {
host: '0.0.0.0',
port: 4000
},
devtool: process.env.NODE_ENV === 'production' ? null : 'eval-source-map'
},
({context, devServer, devtool}) => {
return {
output: {
path: context + '/dist',
publicPath: devtool ? `http://${devServer.host}:${devServer.port}/` : '/'
}
}
}
])
You can run from example folder as webpack --config example/webpack.config.single-file.js
This makes more sense when splitted in multiple files. Check example folder for a sample.
npm i -D webpack-merge-plus
yarn add -D webpack-merge-plus
This project uses Jest for testing.
After cloning and installing dependencies using yarn or npm, just run npm test
.
You're free to contribute to this project by submitting issues and/or pull requests. This project is test-driven, so keep in mind that every change and new feature should be covered by tests. Your name will be added to the hall of fame ;)
This project is licensed under MIT License