webpack-partial
Intelligently compose webpack configuration files.
Usage
npm install --save webpack-partial
Making webpack configurations composable is tricky. So we provide several helpers to ease the composition process. Each helper is of the form (arg1, arg2, ..., webpackConfig)
. All functions are curried and the last argument is always a webpack configuration object allowing you to chain helpers together easily with compose
(or flow
).
Generally:
;;;; const buildConfig = ; const config = ;
But you can also use them individually if you need to:
;; const config = ;
The available helpers are:
- entry
- loader
- output
- plugin
- tap
entry(values, config)
Modify the webpack config entry
object.
// Set the `entry` to `index.js`; // Append `foo.js` to all existing entrypoints.entry;
The entry
function takes either a value to add to entry or a function that maps the existing entry values to new ones. The values property is always an array for consistency even though internally webpack can use objects, strings or arrays.
The callback has this signature:
{ ... }
The key
property represents the key in object-style entrypoints and config
is the existing webpack configuration object.
loader(loader, config)
Add a loader configuration to an existing webpack configuration.
; const babel = ;
output(object, config)
Merge the given output options into the output options in a webpack configuration. You can use it to do things like quickly change the publicPath
.
;const rebase = ;;
plugin(object, config)
Append a plugin to the existing plugins in a webpack configuration.
;; const stats = ;
tap(func, config)
Observe the configuration but ignore any modifications. Can be useful to do things like dumping out a configuration.
;const debug = ;;