Adding custom folder to asset pipeline in Grails

帅比萌擦擦* 提交于 2019-12-30 10:21:27

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/32132532/adding-custom-folder-to-asset-pipeline-in-grails

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!