1

正如标题所述,CSS 和 JS 在本地主机上的 dev 中呈现,它们也在运行 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 生成的战争,我看到 META-INF、WEB-INF 和资产目录。在 assets 目录中,我看到了 grails-app/assets 中的所有文件,以及具有不同扩展名的相同文件,例如 .gz 和 .map 以及文件名后面的哈希值。

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

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


  </head>
  <body>

如您所见,此处没有链接样式表/脚本,并且它们应该存在的空间是空白的。

4

1 回答 1

2

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

runtime "org.grails.plugins:asset-pipeline:3.0.8"
于 2015-09-09T06:26:37.167 回答