3 Configuration - Reference Documentation
Authors:
Version: 3.2.1
3 Configuration
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 themExcludes and Includes
Certain files are not needed for compilation in production. This can be configured globally or for a specific plugin by using the provided configuration options:Property | Value |
---|---|
grails.assets.excludes | ["tiny_mce/src/*.js"] |
grails.assets.plugin."twitter-bootstrap".excludes | ["**/*.less"] |
grails.assets.plugin."twitter-bootstrap".includes | ["bootstrap.less"] |
bootstrap.less
file can be compiled from the twitter-bootstrap plugin
.Minification
The Asset-pipeline comes with the newer version of Closure Compiler to minify your JavaScript assets. This is great for compression and a few options are provided to tune the minifier. Closure can be enabled/disabled entirely as well as configured via various options.Property | Value | Default |
---|---|---|
grails.assets.minifyJs | true or false | true |
grails.assets.minifyCss | true or false | true |
grails.assets.enableSourceMaps | true or false | true |
grails.assets.minifyOptions | Map | (see below) |
grails.assets.skipNonDigests | true or false | true |
It is normally not necessary to turn off 'skipNonDigests'. Tomcat will automatically still serve files by non digest name and will copy them out using storagePath via the `manifest.properties` alias map. This simply cuts storage in half. However, if you are attempting to do things like upload to a cdn outside of the cdn-asset-pipeline plugin and via the contents of 'target/assets'. This may still be useful.
grails.assets.minifyOptions = [
languageMode: 'ES5',
targetLanguage: 'ES5', //Can go from ES6 to ES5 for those bleeding edgers
optimizationLevel: 'SIMPLE' //Or ADVANCED or WHITESPACE_ONLY
]
Mappings and Asset Taglib 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 serve your static assets.To change the URL for your taglibs use the following configuration option:grails.assets.url = "http://cdn.example.com/"
grails.assets.url = { request -> if(request.isSecure()) { return "https://cdn.example.com/" } else { return "http://cdn.example.com/" } }
grails.assets.storagePath = "/var/cdn/path"
mapping
config option.grails.assets.mapping = 'assets'