Skip to content
David Estes edited this page Sep 30, 2013 · 2 revisions

Asset-Pipeline has several customizable options to tweak the compiler to suit your needs. Below is a list of the various configuration options and explanations for how to use them

Plugin Excludes/Includes

Certain files are not needed for compilation in production. This can be configured by using the provided configuration options:

grails.assets.excludes = ["tiny_mce/src/*.js"]

Or Exclude at the plugin level:

  grails.assets.plugin."twitter-bootstrap".excludes = ["**/*.less"]
  grails.assets.plugin."twitter-bootstrap".includes = ["bootstrap.less"]

Above you will notice the use of an includes. An includes allows you to override a specific file after the excludes scan has already been performed. The above example makes sure the bootstrap.less file can be compiled from the twitter-bootstrap plugin.

Minification

The Asset-pipeline comes with the newer version of UglifyJs to minify your javascript assets. This is great for compression and a few options are provided to tune the minifier.

grails.assets.minifyJs = true

The above option can be configured in your applications Config.groovy to enable/disable minification entirely.

To configure the various options of the uglifyjs parse you will want to use the grails.assets.minifyOptions config option. An example of options is provided below:

grails.assets.minifyOptions = [
  strictSemicolons: false,
  mangleOptions: [mangle: true, toplevel: false, defines: null, except: null, no_functions:false],
  genOptions: [indent_start:0, indent_level:4, quote_keys: false, space_colon: false, beautify: false, ascii_only: false, inline_script:false]
]

Above are the default values for the majority of uglify js. For specifics on what these options do please refer to the documentation for uglifyJs. It is worth noting that mangle:true is what mangles variable names and may need to be turned off using this information.

Overriding Mappings and asset tag lib Urls

In many cases you may want to change the url for which to include your static assets. This can be useful when using a CDN or perhaps even using Nginx to server your static assets.

To change the url for your taglibs use the following configuration option:

grails.assets.url = "http://cdn.example.com/"

Now your files are gonna reference the CDN when running in the production environment. To go with this feature, you can have your application automatically copy your asset files out of your base war file on startup of your application.

grails.assets.storagePath = "/var/cdn/path"

You can also change the default tomcat path for both debugging and file inclusion using the mapping config option.

grails.assets.mapping = 'assets'