/* * This is an example build file, demonstrates how to use the build system for * require.js. * * This build file Won't work. It is referencing paths this probably * do not exist on your machine. Just use it as a guide. * * */({//App top-level directory, non-mandatory option. If you specify a value, BaseURL will use this as a relative pathAppdir:"some/path/",//Module root directory. By default, all module resources are relative to this directory. //If the value is not specified, the module is relative to the directory where the build file resides. //If the Appdir value is specified, the module root baseurl is relative appdir. BASEURL:"./",//configuration file directoryMainconfigfile:'. /some/path/to/main.js ',//Set module alias ///REQUIREJS 2.0 can be configured in an array, sequential mapping, the current Polygon module resources are not successfully loaded when the subsequent resources can be loaded sequentiallyPaths: {"Foo.bar":".. /scripts/foo/bar ","Baz":".. /another/path/baz "},//Configure CommonJS's package see http://requirejs.org/docs/api.html#packages for more information.Packagepaths: [], Packages: [],//Specify the output directory, if the value is not specified, the relative build file is located in the directoryDir".. /some/path ",//In Requirejs 2.0.2, all resources of the output directory are deleted before the build //value is true when rebuild is faster, but unexpected exceptions may occur in some special scenariosKeepbuilddir:true,//Internationalization configurationLocale"en -us",//JS file optimization method, currently supports the following several: ///uglify: (default) use UGLIFYJS to compress code //closure: Simple optimization mode using Google's closure Compiler //Closure.keeplines: Use closure, but keep line wrapping //None: Do not compress codeOptimize"Uglify",//Configurable parameters when using Uglifyjs //See Https://github.com/mishoo/UglifyJS for the possible values.Uglify: {toplevel:true, Ascii_only:true, Beautify:true, Max_line_length: +},//Configurable parameters when using Closure CompilerClosure: {compileroptions: {}, Compilationlevel:' Simple_optimizations ', Logginglevel:' WARNING '},//CSS optimization method, currently supports the following several: //None: No compression, merge only //standards: Standard compression, removing comments, wrapping, and code that could cause IE to parse errors //Standard.keeplines: Preserves line breaks In addition to standard compression //standard.keepcomments: Keep annotations In addition to standard compression (R.js 1.0.8+) //Standard.keepComments.keepLines: Retain comments and line breaks in addition to standard compression (R.js 1.0.8+)OPTIMIZECSS:"Standard.keeplines",//Whether to ignore @import directives in CSS resource filesCssimportignore:NULL,//General for command line, multiple CSS resource files can be packaged into a single CSS fileCssin:"Path/to/main.css", Out:"Path/to/css-optimized.css",//Handle all text resource dependencies to avoid a large number of separate XHR requests for loading resourcesInlinetext:true,//whether to turn on strict mode //Because many browsers do not support the strict mode of ES5, the configuration default value is FalseUsestrict:false,//specify build pragmas. If The source files contain comments like so: //>>excludestart ("Fooexclude", pragmas.fooexclude); //>>excludeend ("Fooexclude"); //then The comments that start with//>> is 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 had a choice to use //' has ' code or pragmas, use ' has ' code instead. Pragmas is harder //to read, but they can is 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 have branch //trimming are only do 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" is applied both during the dependency //mapping and file saving phases on an optimization. Some pragmas //should not being 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 is saved as plain JavaScript, the Coffeescript //compiler is no longer needed. In the case, Pragmasonsave would is used //to Exclude the compiler code during the save phase.Pragmasonsave: {//just An exampleExcludecoffeescript: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#hasjsHas: {' Function-bind ':true,' String-trim ':false},//similar to Pragmasonsave, but for have tests--only applied during the //file Save phase of optimization, where "has" are applied to both //dependency Mapping and file save phases.Hasonsave: {' Function-bind ':true,' String-trim ':false},//namespace, complete examples can refer to Http://requirejs.org/docs/faq-advanced.html#renameNamespace' foo ',//Skip pragmas processingSkippragmas:false,//if skipmoduleinsertion is false, then files, does not use define () //to define modules would get a define () placeholder inserted for them. //also, Require.pause/resume calls'll 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, and you //still want to use the optimization tool from Requirejs to concatenate modules //together.Skipmoduleinsertion:false,//specify modules to stubs out in the optimized file. The optimizer would //use The source version of these modules for dependency tracing and for //plugin use, and when writing the text to an optimized layer, these //modules'll get the following text instead: //if the module is used as a plugin: //define ({load:function (id) {throw new Error ("Dynamic Load not allowed:" + ID);}); //if just a plain module: //define ({}); //this is useful particularly for plugins that-inline all their resources //and Use the default module resolution behavior (do *not* implement the //normalize () method). In those cases, a AMD loader just needs to know //that The module has a definition. These small stubs can be used instead of //including The full source for a plugin.Stubmodules: [' text ',' Bar '],//if It isn't 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 if there is some plugins that use things //like XMLHttpRequest that don't work across domains, but the built code //will is placed on another domain.Optimizeallpluginresources:false,//Handles cascading dependencies, which, by default, are capable of dynamically require the cascaded modules at run time. When True, cascading modules are packaged togetherFindnesteddependencies:false,//if set to True, any files that were combined into a build layer would be //removed from the output folder.Removecombined:false, modules: [{//Module alias nameName"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 the This module. //the override ' s value is a object that can //contain any of the other build options on this file. //Override: {pragmas: {fooexclude:true} } },//Package the alias alias Foo/bar/bop and Foo/bar/bee into one file{Name:"Foo/bar/bop", include: ["Foo/bar/bee"] },//FOO/BAR/BIP and its dependencies are packaged, but not included Foo/bar/bop{Name:"Foo/bar/bip", Exclude: ["Foo/bar/bop"] },//Exclude the specified module, but if the module has a cascading dependency on the packaged file, it will still be packaged in{Name:"Foo/bar/bin", Excludeshallow: ["Foo/bar/bot"] },//Insertrequire is introduced in Requirejs 2.0, inserting require ([]) at the end of the built file to trigger the module to load and run //Insertrequire: ["Foo/baz"] that is require (["Foo/baz"]) //For details see Https://github.com/jrburke/almond{Name:"Foo/baz", Insertrequire: ["Foo/baz"] } ],//optimize only individual modules and their dependenciesName"Foo/bar/bop", include: ["Foo/bar/bee"], Insertrequire: [' Foo/bar/bop '], out:"Path/to/optimized-file.js",//An alternative to "include"Deps: ["Foo/bar/bee"],//Requirejs 2.0, out can be a functionOut function (text) { //Custom optimized content},//Module wrapping function, as the name implies using a specific content wrapping module, so that Define/require is no longer a global variable, in the end can expose some global variables for the entire function to useWrap: {start:(function () {", End:"} ());"},//Another module wrapping method //(function () {+ content +} ());Wraptrue,//Another module wrapping method, package content can be specified fileWrap: {startfile:"Part/start.frag", Endfile:"Parts/end.frag"},//Do not optimize some filesFileexclusionregexp:/^\./,//License comment for default reserved modulePreservelicensecomments:true,//Set logging level //trace:0, //Info:1, //Warn:2, //Error:3, //Silent:4 //Default is 0.LogLevel:0,//Operation function for each file module being read, can be transformed in function body appropriatelyOnbuildread: function (modulename, path, contents) { returnContents.replace (/foo/g,' Bar '); },//Operation function when each file module is writtenOnbuildwrite: function (modulename, path, contents) { returnContents.replace (/bar/g,' foo '); },//If True, the optimizer forces a layer of define (require, exports, module) {}) to be wrapped in the fileCjstranslate:true,//introduced in 2.0.2:a bit experimental. //each script in the build layer would be turned into //a JavaScript string with a//@ sourceurl comment, and then wrapped in an //eval call. This allows some browsers to see each evaled script as a //separate script in the script debugger even though they is all combined //in the same file. Some Important Limitations: //1) Do is use in IE if conditional comments is turned on, it'll cause //errors: //http://en.wikipedia.org/wiki/conditional_comment#conditional_comments_in_jscript //2) It is only useful in optimize: ' None ' scenarios. The goal is to allow //easier built layer debugging, which goes against minification desires.Usesourceurl:true})
R.js configuration file Example.build.js incomplete comment