-
Notifications
You must be signed in to change notification settings - Fork 1
Configuration
##web.xml
The ResourceServlet configuration is used to point out the bundle configuration files.
<servlet>
<servlet-name>fnug</servlet-name>
<servlet-class>fnug.ResourceServlet</servlet-class>
<load-on-startup>1</load-on-startup>
<init-param>
<param-name>config</param-name>
<param-value>/bundles.js</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>fnug</servlet-name>
<url-pattern>/rs/*</url-pattern>
</servlet-mapping>
config servlet init parameter is used to point out the bundle configuration file(s). Several files can be used delimiting with comma (,). I.e. /config1.js, /config2.js, /config3.js. Configs are read using Class.getResourceAsStream(), so is relative to the classpath. This means configurations can either be placed in the WEB-INF/classes/ directory in your webapp, or inside a .jar-file in WEB-INF/lib/.
##Bundle Config
The bundle config file, pointed out by the servlet init parameter, configures on or several bundles. The file format is a relaxed JSON to not require keys to be string literals ("basePath": "/foo"`).
{ mybundle1: { basePath: '/stuffhere/, checkModified: 3000, files: [ 'mypackage/sourcefile.js' <-- array of "entry" files for dependency resolution. ], jsCompilerArgs: '--compilation_level ADVANCED_OPTIMIZATIONS', jsLint: '/*jslint white: true, browser: true, onevar: false, undef: true, nomen: true, eqeqeq: true, plusplus: false, bitwise: true, regexp: true, newcap: true, immed: true, maxerr: 100, maxlen: 100 */' }, mybundle2: { ... } }
bundle name - The enclosing object for each section is keyed wth the name for that bundle. In the above example we have two bundles mybundle1 and mybundle2.
basePath (optional) - Class path relative base path for resources served from this bundle. The default value is the same directory the bundle config file is in. Example, if the resource servlet is mounted under /rs/*, the basePath is set to /stuffhere/ and a resource is requested such as /rs/mybundle1/myresource.js, the resulting path being resolved from the classpath would be /stuffhere/mybundle1/myresource.js.
checkModified (optional) - Interval in milliseconds between last modified checks in the bundle. The default value is 3000. Set this to 0 to turn off modified checks for static bundles such as non-changing 3rd party library. For turning off modified checks in deployment, consider using FNUG_OPTS environment variable. The minimum value is 1000 since some file system's minimum time resolution is 1 second.
files (optional) - Files used as entry point when constructing a compressed version of the bundle. This is typically a small set of "entry point" files that uses @requires dependency resolution to drag in the rest of the application. The order of the files is respected as long as no dependency requires the order to be changed. The list can as such be used to declare a set of files to load without using dependency resolution. The files need to be on format [bundle]/[path-to-resource]. Files can either be from the local bundle, i.e. mybundle1/some/file.js or other bundles mybundle2/another.js, note that also files from the local bundle has to have the local bundle name. The type of files that are meaningful to be declared are javascript (.js) and stylesheets (.css), you can mix both.
jsCompilerArgs (optional) - These are compilation options passed directly to the Google Closure Compiler. Default is --warning_level QUIET. Two arguments are, if specified, ignored --js_output_file and --js since these control the input/output of the compiler. For more information look at the closure compiler documentation.
jsLint (optional) - A string of jslint options exactly as output by the www.jslint.com page. If not provided, jslint is turned off. Notice that jslint results are only available when loading resources through the bootstrap with ?debug=1 or other debug flags.