Grails 3.0.1资产管道资产未在生产WAR中链接

时间:2015-06-08 16:55:10

标签: css grails asset-pipeline war grails-3.0

正如标题所述,CSS& JS在localhost上使用dev进行渲染,当运行来自package / war命令的JAR文件时,它们也会渲染。

链接资产清单文件。

<asset:stylesheet href="application.css" />
<asset:javascript src="application.js" />

的grails-app /资产/样式表/ application.css

/*
* This is a manifest file that'll be compiled into application.css, which will include all the files
* listed below.
*
* Any CSS file within this directory can be referenced here using a relative path.
*
* You're free to add application-wide styles to this file and they'll appear at the top of the
* compiled file, but it's generally better to create a new file per style scope.
*
*= require main  
*= require mobile
*= require bootstrap
*= require bootstrap-select
*= require_self
*/

的grails-app /资产/ Javascript角/ application.js中

// This is a manifest file that'll be compiled into application.js.
//
// Any JavaScript file within this directory can be referenced here using a relative path.
//
// You're free to add application-wide JavaScript to this file, but it's generally better
// to create separate JavaScript files as needed. 
//
//= require jquery-2.1.3.js
//= require bootstrap.js
//= require bootstrap-select.js
//= require_tree .
//= require_self

使用war命令查看使用Jenkins生成的war,我看到了META-INF,WEB-INF和assets目录。在assets目录中,我看到了grails-app / assets中的所有文件,以及具有不同扩展名的相同文件,如.gz和.map,以及文件名后的哈希值。

这是作为已部署WAR的页面呈现源。

<!DOCTYPE HTML>
<html>
  <head>
    <title>Knowledge Asset Inventory</title>


  </head>
  <body>

正如您所看到的,这里没有链接的样式表/脚本,它们所在的空间是空白的。

1 个答案:

答案 0 :(得分:2)

asset-pipeline升级到版本3.0.8似乎可以解决问题。

runtime "org.grails.plugins:asset-pipeline:3.0.8"