【发布时间】:2013-08-24 07:00:45
【问题描述】:
我在 assets 目录中有一些模板 HTML 和 JS 文件,结构如下:
app
- assets
- templates
- my_template.html
- javascripts
- application.js
- main.js.erb
其中application.js 包含标准 sprockets 指令://= require main
并且main.js.erb 包含对my_template.html 路径的引用:
main.js.erb:
// 这里有一些代码...
返回 {
pathToTemplate: ""
}
// 这里有更多代码...
在开发中,这很好用。 main.js.erb 被评估为以下内容:
// Some code here ...
return {
pathToTemplate: "assets/my_template.html"
}
// More code here
在生产环境中,资产被预编译(gzip 压缩并删除空格),并在文件名中附加指纹。
Production main.js.erb应该看起来像:
pathToTemplate: "assets/my_template-610dd79b5bb3c20d14b81baa891fc9dd.html"
但与开发中的相同。
是否需要将 Sprockets 配置为也对 HTML 文件进行指纹识别?也许这是一个错误,因为它正在生成一个
带有指纹路径的清单文件,但asset_path 在main.js.erb 中返回非指纹路径?
感谢您的帮助。
【问题讨论】:
标签: javascript ruby-on-rails ruby asset-pipeline sprockets