Adding custom folder to asset pipeline in Grails

前端 未结 1 1543
Happy的楠姐
Happy的楠姐 2021-01-14 02:05

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

1条回答
  •  栀梦
    栀梦 (楼主)
    2021-01-14 02:55

    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
    
    

    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.

    0 讨论(0)
提交回复
热议问题