1 | # lodash-webpack-plugin v0.9.0
|
2 |
|
3 | Create smaller Lodash builds by replacing [feature sets](#feature-sets) of modules
|
4 | with [noop](https://lodash.com/docs#noop), [identity](https://lodash.com/docs#identity),
|
5 | or simpler alternatives.
|
6 |
|
7 | This plugin complements [babel-plugin-lodash](https://www.npmjs.com/package/babel-plugin-lodash)
|
8 | by 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
|
25 | var LodashModuleReplacementPlugin = require('lodash-webpack-plugin');
|
26 | var webpack = require('webpack');
|
27 |
|
28 | module.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 |
|
48 | Opt-in to features with an options object:
|
49 | ```js
|
50 | new LodashModuleReplacementPlugin({
|
51 | 'collections': true,
|
52 | 'paths': true
|
53 | });
|
54 | ```
|
55 |
|
56 | ## Feature Sets
|
57 |
|
58 | The following features are removed by default _(biggest savings first)_:
|
59 |
|
60 | | Feature | Description |
|
61 | |:---|:---|
|
62 | | `shorthands` | Iteratee shorthands for `_.property`, `_.matches`, & `_.matchesProperty`. |
|
63 | | `cloning` | Support for “clone” methods & cloning source objects. |
|
64 | | `currying` | Support for “curry” methods. |
|
65 | | `caching` | Caches for methods like `_.cloneDeep`, `_.isEqual`, & `_.uniq`. |
|
66 | | `collections` | Support for objects in “Collection” methods. |
|
67 | | `exotics` | Support objects like buffers, maps, sets, symbols, typed arrays, etc. |
|
68 | | `guards` | Guards for host objects, sparse arrays, & other edge cases. |
|
69 | | `coercions` | Coercion methods like `_.toInteger`, `_.toNumber`, & `_.toString`. |
|
70 | | `flattening` | Support for “flatten” methods & flattening rest arguments. |
|
71 | | `paths` | Deep property path support for methods like `_.get`, `_.has`, & `_.set`. |
|
72 | | `memoizing` | Support for `_.memoize` & memoization. |
|
73 | | `chaining` | Components to support chain sequences. |
|
74 | | `metadata` | Metadata to reduce wrapping of bound, curried, & partially applied functions.<br>_(requires `currying`)_ |
|
75 | | `placeholders` | Argument placeholder support for “bind”, “curry”, & “partial” methods.<br>_(requires `currying`)_ |
|