forked from lodash/lodash.com
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcustom-builds.html
107 lines (102 loc) · 6.22 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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
---
id: custom-builds
title: Lodash custom builds
layout: default
---
<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="{{ site.links.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:
{% raw %}
<div class="highlight shell"><pre><div>$ npm i -g npm</div><div>$ npm i -g lodash-cli</div><div>$ lodash -h</div></pre></div></p>
{% endraw %}
</section>
<section>
<h2>Build Types</h2>
<ul class="chevron">
<li>Core builds, that are 4 kB, are created using the <code>core</code> modifier.
{% raw %}
<div class="highlight shell"><pre>lodash core</pre></div>
{% endraw %}
</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.
{% raw %}
<div class="highlight shell"><pre>lodash strict</pre></div>
{% endraw %}
</li>
<li>Modularized builds, with Lodash split into modules, are created using the <code>modularize</code> modifier.
{% raw %}
<div class="highlight shell"><pre>lodash modularize</pre></div>
{% endraw %}
</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. <span class="rwd-line">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>.</span>
{% raw %}
<div class="highlight shell"><pre>lodash category=collection,function</pre></div>
{% endraw %}
</li>
<li>Use the <code>exports</code> command to pass comma separated names of ways to export the <code>lodash</code> function. <span class="rwd-line">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>.</span>
{% raw %}
<div class="highlight shell"><pre>lodash exports=amd,node</pre></div>
{% endraw %}
</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.
{% raw %}
<div class="highlight shell"><pre>lodash iife="\!function(window,undefined){%output%}(this)"</pre></div>
{% endraw %}
</li>
<li>Use the <code>include</code> command to pass comma separated names of functions to include in the build.
{% raw %}
<div class="highlight shell"><pre>lodash include=each,filter,map</pre></div>
{% endraw %}
</li>
<li>Use the <code>minus</code> command to pass comma separated function/category names to remove from the build.
{% raw %}
<div class="highlight shell"><pre>lodash minus=result,shuffle</pre></div>
{% endraw %}
</li>
<li>Use the <code>plus</code> command to pass comma separated function/category names to add to the build.
{% raw %}
<div class="highlight shell"><pre>lodash category=array plus=random,template</pre></div>
{% endraw %}
</li>
<li>Use the <code>template</code> command to pass the file path pattern used to match template files to precompile. <span class="rwd-line"><strong>Note:</strong> Precompiled templates are assigned to the <code>_.<span class="me1">templates</span></code> object.</span>
{% raw %}
<div class="highlight shell"><pre>lodash template="./*.jst"</pre></div>
{% endraw %}
</li>
<li>Use the <code>settings</code> command to pass template settings used when precompiling templates.
{% raw %}
<div class="highlight shell"><pre>lodash settings="{interpolate:/\{\{([sS]+?)\}\}/g}"</pre></div>
{% endraw %}
</li>
<li>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. <span class="rwd-line">Use “none” as the module ID to create compiled templates without a dependency on Lodash.</span>
{% raw %}
<div class="highlight shell"><pre>lodash moduleId=underscore</pre></div>
{% endraw %}
</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 class="nowrap">
<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>