lodash-webpack-plugin v0.2.0
Create smaller Lodash builds by replacing feature sets of modules
with noop, identity,
or simpler alternatives.
This plugin complements babel-plugin-lodash
by shrinking its cherry-picked builds even further!
Install
$ npm i --save lodash
$ npm i --save-dev lodash-webpack-plugin babel-core babel-loader babel-plugin-lodash babel-preset-es2015 webpack
Example
Usage
webpack.config.js
var LodashModuleReplacementPlugin = require('lodash-webpack-plugin');
var webpack = require('webpack');
module.exports = {
'module': {
'loaders': [{
'loader': 'babel',
'test': /\.js$/,
'exclude': /node_modules/,
'query': {
'plugins': ['lodash'],
'presets': ['es2015']
}
}]
},
'plugins': [
new LodashModuleReplacementPlugin,
new webpack.optimize.OccurenceOrderPlugin,
new webpack.optimize.UglifyJsPlugin
]
};
Opt-in to features with an options object:
new LodashModuleReplacementPlugin({
'collections': true,
'paths': true
});
Feature Sets
The following features are removed by default (biggest savings first):
Feature | Description |
---|
shorthands | Iteratee shorthands for _.property , _.matches , & _.matchesProperty . |
collections | Support objects in “Collection” methods like _.each , _.filter , & _.map . |
currying | Support for _.curry & _.curryRight . |
caching | Caches using Map & Set for methods like _.cloneDeep , _.isEqual , & _.uniq . |
coercions | Coercion methods like _.toInteger , _.toNumber , & _.toString . |
paths | Deep property path support for methods like _.get , _.has , & _.set . |
guards | Dense array & iteratee call guards for methods like _.every , _.keys , & _.some . |
metadata | Store metadata to reduce wrapping of bound, curried, & partially applied functions. (requires currying ) |
placeholders | Argument placeholder support for methods like _.bind , _.curry , & _.partial . (requires currying ) |