【问题标题】:Grails 3.0.1 Asset Pipeline Assets not Linking in Production WARGrails 3.0.1 资产管道资产未在生产 WAR 中链接
【发布时间】:2015-08-23 06:17:58
【问题描述】:

正如标题所述,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 目录。在 assets 目录中,我看到了 grails-app/assets 中的所有文件,以及具有不同扩展名的相同文件,例如 .gz 和 .map 以及文件名后面的哈希值。

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

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


  </head>
  <body>

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

【问题讨论】:

  • 你找到解决办法了吗?

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


【解决方案1】:

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

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

【讨论】:

  • 这确实解决了它。 Grails 3.0.5 还发布了一个修复程序,因此升级到该版本也应该可以解决问题。
猜你喜欢
  • 2016-02-09
  • 2017-02-06
  • 2023-03-10
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多