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

Grails 3.0.1 Asset Pipeline Assets not Linking in Production WAR

如标题所述,CSS 和 JS 在本地主机上的开发中呈现,当来自 package/war 命令的 JAR 文件为 运行.

时,它们也会呈现

正在链接资产清单文件。

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

grails-app/assets/stylesheets/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/assets/javascripts/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>

如您所见,此处没有 stylesheets/scripts 链接,space 本应是空白的。

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

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