Custom builds
Custom builds make it easy to create lightweight versions of lodash containing only the features you need. To top it off, we handle all function dependency & alias mapping for you. Review the build differences & pick the one that’s right for you.
Using Grunt? We also provide a Grunt plugin to build lodash as part of your Gruntfile.
The lodash command-line utility is available when lodash-cli is installed as a global package:
$ {sudo -H} npm i -g npm
$ {sudo -H} npm i -g lodash-cli
$ lodash -h
Note: Uninstall older versions before installing lodash-cli.
- Compat builds, with support for old & new environments, are created using the
compatmodifier. (default)
lodash compat
- Modern builds, tailored for newer environments with ES5/ES6 support, are created using the
modernmodifier.
lodash modern
- Strict builds, with ES strict mode enabled, are created using the
strictmodifier.
lodash strict
- Modularized builds, splitting lodash into modules, are created using the
modularizemodifier.
lodash modularize
Build commands:
- Use the
categorycommand to pass comma separated categories of functions to include in the build. Valid categories are “array”, “chain”, “collection”, “date”, “function”, “lang”, “object”, “number”, “string”, & “utility”.
lodash category=collection,function
- Use the
exportscommand to pass comma separated names of ways to export thelodashfunction. Valid exports are “amd”, “commonjs”, “es”, “global”, “iojs”, “node”, “npm”, “none”, & “umd”.
lodash exports=amd,commonjs,iojs
- Use the
iifecommand to specify code to replace the IIFE that wraps lodash.
lodash iife="!function(window,undefined){%output%}(this)"
- Use the
includecommand to pass comma separated names of functions to include in the build.
lodash include=each,filter,map
- Use the
minuscommand to pass comma separated function/category names to remove from the build.
lodash modern minus=result,shuffle
- Use the
pluscommand to pass comma separated function/category names to add to the build.
lodash category=array plus=random,template
- Use the
templatecommand to pass the file path pattern used to match template files to precompile. Note: Precompiled templates are assigned to the_.<span class="me1">templates</span>object.
lodash template="./*.jst"
- Use the
settingscommand to pass template settings used when precompiling templates.
lodash settings="{interpolate:/\{\{([\s\S]+?)\}\}/g}"
- Use the
moduleIdcommand to specify the AMD module ID for lodash or the module ID used to include lodash in compiled templates. Use “none” as the module ID to create compiled templates without a dependency on lodash.
lodash moduleId=underscore
Notes:
- All commands except
compat&modernmay be combined - The
exportsvalues “es” & “npm” may only be used in conjunction with themodularizecommand - The
modularizecommand uses the firstexportsvalues as its module format, ignoring subsequent values. - Unless specified by
-oor--outputall files created are saved to the current working directory - Node.js 0.10.8-0.10.11 have bugs preventing minified builds
The following options are also supported:
-c, --stdout .......... Write output to standard output
-d, --development ..... Write only the non-minified development output
-h, --help ............ Display help information
-m, --source-map ...... Generate a source map using an optional source map URL
-o, --output .......... Write output to a given path/filename
-p, --production ...... Write only the minified production output
-s, --silent .......... Skip status updates normally logged to the console
-V, --version ......... Output current version of lodash