Compiling and minifying JavaScript files in the web UI framework
You can compile and minify JavaScript files in the web UI framework. However, minification will only combine the JavaScript files.
About this task
Procedure
- Run the jscompile
command to get possible JavaScript compilation
warnings using the sci_ant.sh command from the INSTALL_DIR/bin
directory. This command works with the jsUtil.xml file in the same
directory. This command can include the following properties:
Note: This is an optional step and not a requirement for minification.
gis.install: Installation directory path.
srcDir: Source directory.
errorOnly: Indicates whether to check for all warnings and errors (false) or for errors only (true). Defaults to false.
format: Output format - (h) for HTML/(t) for text. Defaults to t. If errorOnly is set to true, only HTML (h) is the valid option.
outputFile: Output file path. If file path is not provided or file doesn't exist. all warnings will be directed to standard output.
warningOptions: Warning options (comma separated). Default options: [onevar, undef, forin, debug, browser, eqeqeq, newcap, evil]. For all warning options, see the JSLint website.
For example:./sci_ant.sh –f jsUtil.xml jscompile –Dgis.install=INSTALL_DIR –DsrcDir=INSTALL_DIR/repository/eardata/platform_uifwk/version/war/platform
Note: If you are using sci_ant.sh, then gis.install becomes optional. - Combine your files into one file by minifying
the files using the sci_ant.sh command from the INSTALL_DIR/bin directory. This
command works with the jsUtil.xml file in the same directory. This command can include the following
properties:
- gis.install: Installation directory path.
-
jsbDir: JSB directory path (mandatory).
-
srcDir: Source directory. Will be used if input attribute is not specified in JSB. Optional.
-
destDir: Destination directory. Will be used if input attribute is not specified in JSB. Optional.
-
createIndividualFile: Indicates whether to create individual files (true/false). Defaults to false (do not create individual files). Optional.
- jscompile: Indicates whether to get JavaScript warning/errors (true/false). Defaults to true (get errors).
For example:./sci_ant.sh –f jsUtil.xml minify-js –Dgis.install=INSTALL_DIR –DsrcDir=INSTALL_DIR/repository/eardata/platform_uifwk/version/war -DjsbDir=INSTALL_DIR/repository/eardata/platform_uifwk/version/war/builder –DdestDir=INSTALL_DIR/repository/eardata/platform_uifwk/version/war
where version is either 20 or 30 depending on if you are using Ext JS 2 or Ext JS 3 JavaScript-related files/content.Note: If you are using sci_ant.sh, then gis.install becomes optional.If minification is required for extended JavaScript files, you should create an extn folder within the directory where overlays/extensions are added (INSTALL_DIR/extensions/application name/webpages). Copy all of the files to be minified to that directory. You must follow the process of creating the same relative directory structure for extensibility. You can then run the minification script successfully because the minified file path in the JSB file does exist.
When you run the buildear/buildwar script, the following happens:
-
First, all contents of the overlays/extensions directory except the extn directory are copied to the application war/extn directory.
- Then, the contents of the extn directory in the overlays/extensions directory get copied to the application war/extn directory. As the contents of this directory are copied last, it would override the contents contributed by overlays/extensions directory in case of a conflict (same directory structure).