UNPKG

2.5 kBMarkdownView Raw
1# lodash-webpack-plugin v0.5.0
2
3Create smaller Lodash builds by replacing [feature sets](#feature-sets) of modules
4with [noop](https://lodash.com/docs#noop), [identity](https://lodash.com/docs#identity),
5or simpler alternatives.
6
7This plugin complements [babel-plugin-lodash](https://www.npmjs.com/package/babel-plugin-lodash)
8by shrinking its cherry-picked builds even further!
9
10## Install
11
12```bash
13$ npm i --save lodash
14$ npm i --save-dev lodash-webpack-plugin babel-core babel-loader babel-plugin-lodash babel-preset-es2015 webpack
15```
16
17## Example
18
19![demo](https://cloud.githubusercontent.com/assets/4303/15064867/2c5420b0-130e-11e6-8293-5037d359851f.gif)
20
21## Usage
22
23###### webpack.config.js
24```js
25var LodashModuleReplacementPlugin = require('lodash-webpack-plugin');
26var webpack = require('webpack');
27
28module.exports = {
29 'module': {
30 'loaders': [{
31 'loader': 'babel',
32 'test': /\.js$/,
33 'exclude': /node_modules/,
34 'query': {
35 'plugins': ['lodash'],
36 'presets': ['es2015']
37 }
38 }]
39 },
40 'plugins': [
41 new LodashModuleReplacementPlugin,
42 new webpack.optimize.OccurenceOrderPlugin,
43 new webpack.optimize.UglifyJsPlugin
44 ]
45};
46```
47
48Opt-in to features with an options object:
49```js
50new LodashModuleReplacementPlugin({
51 'collections': true,
52 'paths': true
53});
54```
55
56## Feature Sets
57
58The following features are removed by default _(biggest savings first)_:
59
60| Feature | Description |
61|:---|:---|
62| `shorthands` | Iteratee shorthands for `_.property`, `_.matches`, & `_.matchesProperty`. |
63| `collections` | Support for objects in “Collection” methods. |
64| `currying` | Support for “curry” methods. |
65| `caching` | Caches for methods like `_.cloneDeep`, `_.isEqual`, & `_.uniq`. |
66| `coercions` | Coercion methods like `_.toInteger`, `_.toNumber`, & `_.toString`. |
67| `guards` | Guards for `arguments` objects, host objects, sparse arrays, & other edge cases. |
68| `flattening` | Support for “flatten” methods & flattening arguments. |
69| `paths` | Deep property path support for methods like `_.get`, `_.has`, & `_.set`. |
70| `memoizing` | Support for `_.memoize` & memoization. |
71| `chaining` | Components to support chain sequences. |
72| `metadata` | Metadata to reduce wrapping of bound, curried, & partially applied functions.<br>_(requires `currying`)_ |
73| `placeholders` | Argument placeholder support for “bind”, “curry”, & “partial” methods.<br>_(requires `currying`)_ |