webpack-super

a functional approach to writing webpack configs

Usage no npm install needed!

<script type="module">
  import webpackSuper from 'https://cdn.skypack.dev/webpack-super';
</script>

README

webpack-super

Build Status npm Coverage Status Donate Bitcoin

a functional approach to writing webpack configs

Installation

npm install webpack-super --save

Functions

appendAt(path, value, obj) ⇒ object

Creates a new object with the value set at the path provided and copy the rest.

Kind: global function
Implements: Transformer

Param Type Description
path string path string where the value needs to be set
value any the value that needs to be set
obj object the object that needs to be transformed

compose(...funcs) ⇒ function

Creates a composition factory functions

Kind: global function
Implements: Helper

Param Type Description
...funcs function factory functions

copy(path, source, destination) ⇒ object

Copies a value at a path from source to destination

Kind: global function
Implements: Transformer

Param Type Description
path string path string where the value needs to be picked/set
source object source object from where the value needs to be picked
destination object destination object where the value needs to be set

Example

copy('a.b', {a: {b: 100}}, {p: 100}) // outputs: {a: {b: 100}, q: 100}

setAt(path, value, obj) ⇒ object

Creates a new object with the value set at the path provided and copy the rest.

Kind: global function
Implements: Transformer
Returns: object - the new object with the value

Param Type Description
path string path string where the value needs to be set
value any the value that needs to be set
obj object the object that needs to be transformed

Example

setAt('entry', './src/main.js', {}) // outputs: {entry: './src/main.js'}
setAt('output.filename', '[hash].bundle.js', {}) // outputs: {output: {filename: '[hash].bundle.js'}}

when(condition, func) ⇒ function

Returns a new function that is either has no effect (identity) or or has the same as the passed func based on the condition.

Kind: global function
Implements: Transformer

Param Type Description
condition boolean the condition
func function the function to be called