-
Notifications
You must be signed in to change notification settings - Fork 673
/
example.build.js
268 lines (239 loc) · 11.6 KB
/
example.build.js
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
/*
* This is an example build file that demonstrates how to use the build system for
* require.js.
*
* THIS BUILD FILE WILL NOT WORK. It is referencing paths that probably
* do not exist on your machine. Just use it as a guide.
*
*
*/
({
//The top level directory that contains your app. If this option is used
//then it assumed your scripts are in a subdirectory under this path.
//This option is not required. If it is not specified, then baseUrl
//below is the anchor point for finding things. If this option is specified,
//then all the files from the app directory will be copied to the dir:
//output area, and baseUrl will assume to be a relative path under
//this directory.
appDir: "some/path/",
//By default, all modules are located relative to this path. If baseUrl
//is not explicitly set, then all modules are loaded relative to
//the directory that holds the build file.
baseUrl: "./",
//Set paths for modules. If relative paths, set relative to baseUrl above.
//If a special value of "empty:" is used for the path value, then that
//acts like mapping the path to an empty file. It allows the optimizer to
//resolve the dependency to path, but then does not include it in the output.
//Useful to map module names that are to resources on a CDN or other
//http: URL when running in the browser and during an optimization that
//file should be skipped because it has no dependencies.
paths: {
"foo.bar": "../scripts/foo/bar",
"baz": "../another/path/baz"
},
//Configure CommonJS packages. See http://requirejs.org/docs/api.html#packages
//for more information.
packagePaths: [],
packages: [],
//The directory path to save the output. If not specified, then
//the path will default to be a directory called "build" as a sibling
//to the build file. All relative paths are relative to the build file.
dir: "../some/path",
//Used to inline i18n resources into the built file. If no locale
//is specified, i18n resources will not be inlined. Only one locale
//can be inlined for a build. Root bundles referenced by a build layer
//will be included in a build layer regardless of locale being set.
locale: "en-us",
//How to optimize all the JS files in the build output directory.
//Right now only the following values
//are supported:
//- "uglify": (default) uses UglifyJS to minify the code.
//- "closure": uses Google's Closure Compiler in simple optimization
//mode to minify the code. Only available if running the optimizer using
//Java.
//- "closure.keepLines": Same as closure option, but keeps line returns
//in the minified files.
//- "none": no minification will be done.
optimize: "uglify",
//If using UglifyJS for script optimization, these config options can be
//used to pass configuration values to UglifyJS.
//See https://github.com/mishoo/UglifyJS for the possible values.
uglify: {
gen_codeOptions: {},
strict_semicolons: {},
do_toplevel: {},
ast_squeezeOptions: {}
},
//If using Closure Compiler for script optimization, these config options
//can be used to configure Closure Compiler. See the documentation for
//Closure compiler for more information.
closure: {
CompilerOptions: {},
CompilationLevel: 'SIMPLE_OPTIMIZATIONS',
loggingLevel: 'WARNING'
}
//Allow CSS optimizations. Allowed values:
//- "standard": @import inlining, comment removal and line returns.
//Removing line returns may have problems in IE, depending on the type
//of CSS.
//- "standard.keepLines": like "standard" but keeps line returns.
//- "none": skip CSS optimizations.
optimizeCss: "standard.keepLines",
//If optimizeCss is in use, a list of of files to ignore for the @import
//inlining. The value of this option should be a comma separated list
//of CSS file names to ignore. The file names should match whatever
//strings are used in the @import calls.
cssImportIgnore: null,
//Inlines the text for any text! dependencies, to avoid the separate
//async XMLHttpRequest calls to load those dependencies.
inlineText: true,
//Allow "use strict"; be included in the RequireJS files.
//Default is false because there are not many browsers that can properly
//process and give errors on code for ES5 strict mode,
//and there is a lot of legacy code that will not work in strict mode.
useStrict: false,
//Specify build pragmas. If the source files contain comments like so:
//>>excludeStart("fooExclude", pragmas.fooExclude);
//>>excludeEnd("fooExclude");
//Then the comments that start with //>> are the build pragmas.
//excludeStart/excludeEnd and includeStart/includeEnd work, and the
//the pragmas value to the includeStart or excludeStart lines
//is evaluated to see if the code between the Start and End pragma
//lines should be included or excluded. If you have a choice to use
//"has" code or pragmas, use "has" code instead. Pragmas are harder
//to read, but they can be a bit more flexible on code removal vs.
//has-based code, which must follow JavaScript language rules.
//Pragmas also remove code in non-minified source, where has branch
//trimming is only done if the code is minified via UglifyJS or
//Closure Compiler.
pragmas: {
fooExclude: true
},
//Same as "pragmas", but only applied once during the file save phase
//of an optimization. "pragmas" are applied both during the dependency
//mapping and file saving phases on an optimization. Some pragmas
//should not be processed during the dependency mapping phase of an
//operation, such as the pragma in the CoffeeScript loader plugin,
//which wants the CoffeeScript compiler during the dependency mapping
//phase, but once files are saved as plain JavaScript, the CoffeeScript
//compiler is no longer needed. In that case, pragmasOnSave would be used
//to exclude the compiler code during the save phase.
pragmasOnSave: {
//Just an example
excludeCoffeeScript: true
},
//Allows trimming of code branches that use has.js-based feature detection:
//https://github.com/phiggins42/has.js
//The code branch trimming only happens if minification with UglifyJS or
//Closure Compiler is done. For more information, see:
//http://requirejs.org/docs/optimization.html#hasjs
has: {
'function-bind': true,
'string-trim': false
},
//Similar to pragmasOnSave, but for has tests -- only applied during the
//file save phase of optimization, where "has" is applied to both
//dependency mapping and file save phases.
hasOnSave: {
'function-bind': true,
'string-trim': false
},
//Allows namespacing requirejs, require and define calls to a new name.
//This allows stronger assurances of getting a module space that will
//not interfere with others using a define/require AMD-based module
//system. The example below will rename define() calls to foo.define().
//See http://requirejs.org/docs/faq-advanced.html#rename for a more
//complete example.
namespace: 'foo',
//Skip processing for pragmas.
skipPragmas: false,
//If skipModuleInsertion is false, then files that do not use define()
//to define modules will get a define() placeholder inserted for them.
//Also, require.pause/resume calls will be inserted.
//Set it to true to avoid this. This is useful if you are building code that
//does not use require() in the built project or in the JS files, but you
//still want to use the optimization tool from RequireJS to concatenate modules
//together.
skipModuleInsertion: false,
//If it is not a one file optimization, scan through all .js files in the
//output directory for any plugin resource dependencies, and if the plugin
//supports optimizing them as separate files, optimize them. Can be a
//slower optimization. Only use if there are some plugins that use things
//like XMLHttpRequest that do not work across domains, but the built code
//will be placed on another domain.
optimizeAllPluginResources: false,
//List the modules that will be optimized. All their immediate and deep
//dependencies will be included in the module's file when the build is
//done. If that module or any of its dependencies includes i18n bundles,
//only the root bundles will be included unless the locale: section is set above.
modules: [
//Just specifying a module name means that module will be converted into
//a built file that contains all of its dependencies. If that module or any
//of its dependencies includes i18n bundles, they may not be included in the
//built file unless the locale: section is set above.
{
name: "foo/bar/bop",
//For build profiles that contain more than one modules entry,
//allow overrides for the properties that set for the whole build,
//for example a different set of pragmas for this module.
//The override's value is an object that can
//contain any of the other build options in this file.
override: {
pragmas: {
fooExclude: true
}
}
},
//This module entry combines all the dependencies of foo/bar/bop and foo/bar/bee
//and any of their dependencies into one file.
{
name: "foo/bar/bop",
include: ["foo/bar/bee"]
},
//This module entry combines all the dependencies of foo/bar/bip into one file,
//but excludes foo/bar/bop and its dependencies from the built file. If you want
//to exclude a module that is also another module being optimized, it is more
//efficient if you define that module optimization entry before using it
//in an exclude array.
{
name: "foo/bar/bip",
exclude: [
"foo/bar/bop"
]
},
//This module entry shows how to specify a specific module be excluded
//from the built module file. excludeShallow means just exclude that
//specific module, but if that module has nested dependencies that are
//part of the built file, keep them in there. This is useful during
//development when you want to have a fast bundled set of modules, but
//just develop/debug one or two modules at a time.
{
name: "foo/bar/bin",
excludeShallow: [
"foo/bar/bot"
]
}
],
//Wrap any build layer in a start and end text specified by wrap.
//Use this to encapsulate the module code so that define/require are
//not globals. The end text can expose some globals from your file,
//making it easy to create stand-alone libraries that do not mandate
//the end user use requirejs.
wrap: {
start: "(function() {",
end: "}());"
},
//Another way to use wrap, but uses default wrapping of:
//(function() { + content + }());
wrap: true,
//Another way to use wrap, but uses file paths. This makes it easier
//to have the start text contain license information and the end text
//to contain the global variable exports, like
//window.myGlobal = requirejs('myModule');
//File paths are relative to the build file, or if running a commmand
//line build, the current directory.
wrap: {
startFile: "part/start.frag",
endFile: "parts/end.frag"
}
})