forked from lodash/lodash.com
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcustom-builds.html
83 lines (78 loc) · 6.95 KB
/
custom-builds.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
---
id: custom-builds
title: Lodash custom builds
layout: default
---
{% raw %}
<section>
<h1>Custom Builds</h1>
<p>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 <a href="https://github.com/lodash/lodash/wiki/build-differences">build differences</a> & pick the one that’s right for you.</p>
<p>The Lodash command-line interface is available when <a href="https://npmjs.org/package/lodash-cli"><code>lodash-cli</code></a> is installed as a global package:
<div class="highlight shell"><pre><div><span class="source shell"><span>$ npm i -g npm</span></span></div><div><span class="source shell"><span>$ npm i -g lodash-cli</span></span></div><div><span class="source shell"><span>$ lodash -h</span></span></div></pre></div></p>
</section>
<section>
<h2>Build Types</h2>
<ul class="chevron">
<li>Core builds, that are 4 kB, are created using the <code>core</code> modifier.
<div class="highlight shell"><pre><div><span class="source shell"><span>lodash core</span></span></div></pre></div>
</li>
<li>Strict builds, with <a href="http://www.ecma-international.org/ecma-262/7.0/#sec-strict-mode-of-ecmascript">ES strict mode</a> enabled, are created using the <code>strict</code> modifier.
<div class="highlight shell"><pre><div><span class="source shell"><span>lodash strict</span></span></div></pre></div>
</li>
<li>Modularized builds, with Lodash split into modules, are created using the <code>modularize</code> modifier.
<div class="highlight shell"><pre><div><span class="source shell"><span>lodash modularize</span></span></div></pre></div>
</li>
</ul>
</section>
<section>
<h2>Build Commands:</h2>
<ul class="chevron">
<li>Use the <code>category</code> command to pass comma separated categories of functions to include in the build.<br>Valid categories are <em>“array”</em>, <em>“collection”</em>, <em>“date”</em>, <em>“function”</em>, <em>“lang”</em>, <em>“object”</em>, <em>“number”</em>, <em>“seq”</em>, <em>“string”</em>, & <em>“util”</em>.
<div class="highlight shell"><pre><div><span class="source shell"><span>lodash category=collection,function</span></span></div></pre></div>
</li>
<li>Use the <code>exports</code> command to pass comma separated names of ways to export the <code>lodash</code> function.<br>Valid exports are <em>“amd”</em>, <em>“commonjs”</em>, <em>“es”</em>, <em>“global”</em>, <em>“node”</em>, <em>“npm”</em>, <em>“none”</em>, & <em>“umd”</em>.
<div class="highlight shell"><pre><div><span class="source shell"><span>lodash exports=amd,node</span></span></div></pre></div>
</li>
<li>Use the <code>iife</code> command to specify code to replace the <a href="http://benalman.com/news/2010/11/immediately-invoked-function-expression/">IIFE</a> that wraps Lodash.
<div class="highlight shell"><pre><div><span class="source shell"><span>lodash iife=</span><span class="string shell"><span class="string shell"><span>"</span></span><span>\!function(window,undefined){%output%}(this)</span><span class="string shell"><span>"</span></span></span></span></div></pre></div>
</li>
<li>Use the <code>include</code> command to pass comma separated names of functions to include in the build.
<div class="highlight shell"><pre><div><span class="source shell"><span>lodash include=each,filter,map</span></span></div></pre></div>
</li>
<li>Use the <code>minus</code> command to pass comma separated function/category names to remove from the build.
<div class="highlight shell"><pre><div><span class="source shell"><span>lodash minus=result,shuffle</span></span></div></pre></div>
</li>
<li>Use the <code>plus</code> command to pass comma separated function/category names to add to the build.
<div class="highlight shell"><pre><div><span class="source shell"><span>lodash category=array plus=random,template</span></span></div></pre></div>
</li>
<li>Use the <code>template</code> command to pass the file path pattern used to match template files to precompile.<br><strong>Note:</strong> Precompiled templates are assigned to the <code>_.<span class="me1">templates</span></code> object.
<div class="highlight shell"><pre><div><span class="source shell"><span>lodash template=</span><span class="string shell"><span class="string shell"><span>"</span></span><span>./*.jst</span><span class="string shell"><span>"</span></span></span></span></div></pre></div>
</li>
<li>Use the <code>settings</code> command to pass template settings used when precompiling templates.
<div class="highlight shell"><pre><div><span class="source shell"><span>lodash settings=</span><span class="string shell"><span class="string shell"><span>"</span></span><span>{interpolate:/\{\{([sS]+?)\}\}/g}</span><span class="string shell"><span>"</span></span></span></span></div></pre></div>
</li>
<li class="last-item">Use the <code>moduleId</code> command to specify the AMD module ID for Lodash or the module ID used to include Lodash in compiled templates.<br>Use “none” as the module ID to create compiled templates without a dependency on Lodash.
<div class="highlight shell"><pre><div><span class="source shell"><span>lodash moduleId=underscore</span></span></div></pre></div>
</li>
</ul>
</section>
<section>
<h2>Notes:</h2>
<ul class="chevron">
<li>The <code>exports</code> values <em>“es”</em> & <em>“npm”</em> may only be used in conjunction with the <code>modularize</code> command</li>
<li>The <code>modularize</code> command uses the first <code>exports</code> values as its module format, ignoring subsequent values</li>
<li>Unless specified by <code>-o</code> or <code>--output</code> all files created are saved to the current working directory</li>
</ul>
<p>The following options are also supported:</p>
<ul>
<li><code>-c</code>, <code>--stdout</code> ................ Write output to standard output</li>
<li><code>-d</code>, <code>--development</code> ..... Write only the non-minified development output</li>
<li><code>-h</code>, <code>--help</code> .................... Display help information</li>
<li><code>-m</code>, <code>--source-map</code> ....... Generate a source map using an optional source map URL</li>
<li><code>-o</code>, <code>--output</code> ................ Write output to a given path/filename</li>
<li><code>-p</code>, <code>--production</code> ....... Write only the minified production output</li>
<li><code>-s</code>, <code>--silent</code> ............... Skip status updates normally logged to the console</li>
<li><code>-V</code>, <code>--version</code> ............. Output current version of Lodash</li>
</ul>
</section>
{% endraw %}