Twitter bootstrap 在Grails3应用程序中引用引导的最佳方式

Twitter bootstrap 在Grails3应用程序中引用引导的最佳方式,twitter-bootstrap,grails,grails-3.0,Twitter Bootstrap,Grails,Grails 3.0,我想把Twitter的引导程序引入我的Grails3应用程序。最好的方法是什么?我既不想将源代码置于版本控制之下,也不想引用远程CDN 在我的build.gradle中添加“org.grails:grails bootstrap:3.0.1”作为编译依赖项会拉下相关的JAR,但是我如何将其插入到我的应用程序中,最终能够从我的视图/gsp引用引导类呢?您应该使用,文档会准确地告诉您该做什么 Javascript grails app/assets/javascripts/application.j

我想把Twitter的引导程序引入我的Grails3应用程序。最好的方法是什么?我既不想将源代码置于版本控制之下,也不想引用远程CDN

在我的
build.gradle
中添加
“org.grails:grails bootstrap:3.0.1”
作为编译依赖项会拉下相关的JAR,但是我如何将其插入到我的应用程序中,最终能够从我的视图/gsp引用引导类呢?

您应该使用,文档会准确地告诉您该做什么

Javascript grails app/assets/javascripts/application.js:

//= require bootstrap
//= require jquery-2.1.3.js
//= require_tree .
//= require_self
//= require /webjars/bootstrap/3.3.5/js/bootstrap.min
//= require /webjars/bootstrap-tagsinput/0.5/bootstrap-tagsinput
//= require /webjars/typeaheadjs/0.11.1/typeahead.bundle.js
样式表grails app/assets/javascripts/application.css:

/*
*= require bootstrap
*/
/*
*= require main
*= require mobile
*= require_self
*= require /webjars/bootstrap/3.3.5/css/bootstrap-theme
*= require /webjars/bootstrap/3.3.5/css/bootstrap
*= require /webjars/bootstrap-tagsinput/0.5/bootstrap-tagsinput
*/

我认为Grails3还没有任何可用的引导插件。我认为在项目中包含引导,然后在gsp或布局中引用文件更容易

我还没有一个可行的示例,但请看下面的代码片段:
Webjars对我很有用,我在我的
应用程序.js
应用程序.css
中使用了Webjars链接,但这些链接并不总是定义得很好(请参见typeahead示例)

application.js:

//= require bootstrap
//= require jquery-2.1.3.js
//= require_tree .
//= require_self
//= require /webjars/bootstrap/3.3.5/js/bootstrap.min
//= require /webjars/bootstrap-tagsinput/0.5/bootstrap-tagsinput
//= require /webjars/typeaheadjs/0.11.1/typeahead.bundle.js
application.css:

/*
*= require bootstrap
*/
/*
*= require main
*= require mobile
*= require_self
*= require /webjars/bootstrap/3.3.5/css/bootstrap-theme
*= require /webjars/bootstrap/3.3.5/css/bootstrap
*= require /webjars/bootstrap-tagsinput/0.5/bootstrap-tagsinput
*/
我正在使用这个插件,并在
.gitignore
中添加了以下路径,以便在第一次运行时下载资源

/grails-app/assets/javascripts/bootstrap
/grails-app/assets/javascripts/bootstrap-all.js
/grails-app/assets/stylesheets/font-awesome
/grails-app/assets/stylesheets/bootstrap
/grails-app/assets/stylesheets/font-awesome-less.less
/grails-app/assets/stylesheets/bootstrap-less.less
/grails-app/assets/stylesheets/bootstrap-all.css
/grails-app/assets/stylesheets/font-awesome-all.css

嗨,格雷格。该文档引用了BuildConfig.groovy,我认为它在Grails3中已经停止使用了。你能建议如何以“新”的方式引用这个插件吗?你不把它添加到build.gradle中吗?对不起,我真的不确定。我在避开圣杯3.:)假设它仍在使用资产管道,我仍然相信它是适用的。您如何引用webjars?作为依赖?我在编译过程中收到错误,即没有此类资产“/webjars/bootstrap/3.3.5/css/bootstrap主题”和所有其他链接。在grails的缓存中,我看到了webjar,但它似乎应该放在grails项目的“资产”文件夹中?您需要在build.gradle文件中添加依赖项(请参阅以查找您需要的依赖项)。对于bootstrap 3.3.5,它是:
compile'org.webjars:bootstrap:3.3.5'
。是的,我在写评论之前已经做过了。因此,依赖项会出现错误。执行的一些其他操作?不
dependencies{…compile“org.grails:grails web boot”compile'org.webjars:typeaheadjs:0.11.1“compile”org.webjars:bootstrap:3.3.5“compile”org.webjars:bootstrap标记输入:0.5“compile”org.webjars.bower:bootstrap表:1.8.1“…运行时“org.grails.plugins:asset pipeline”…//注意:建议更新到更健壮的驱动程序(Chrome、Firefox等)testRuntime'org.seleniumhq.selenium:selenium htmlunit驱动程序:2.44.0'控制台“org.grails:grails控制台”}
。我会查的,谢谢。你能展示一下你是如何将webjar添加到你的项目中的吗?你找到解决这个问题的方法了吗?你能把结果记录下来吗?有趣的是,application.css中已经有对bootstrap的引用。