I have a Grails application. I have the js, css and image folder in the web-app and in the same folder I have a themes folder. I am planning to use the asset pipeline plugin. How should I use my themes folder? I have files with the same names in the core folders and the themes folder. Any help on this?
Custom folders are supported in the asset pipeline. I will show you an example using Bootstrap.
We create a root level directory in the assets folder called themes, this is where we will store third party scripts. You can name this anything you like, E.G., lib, libraries, vendor, plugins.
assets/
images/
javascript/
application.js
stylesheets/
application.css
themes/
bootstrap/
js/
bootstrap.js
bootstrap.min.js
css/
bootstrap.css
bootstrap.min.css
You can then access these files from the custom folder like so:
// application.js
//= require bootstrap/js/bootstrap.js
// application.css
/*= require bootstrap/css/bootstrap.css */
// In a gsp
<asset:javascript src="bootstrap/js/bootstrap.js"/>
The require directives ignore the first directory in the asset folder. This allows you to modularise and organise your assets nicely.
You might need to restart your grails application when adding a new top level asset directory.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With