【发布时间】:2014-05-30 03:58:44
【问题描述】:
我想在生产(heroku)中提供一个特定的 js 文件,而不需要时间戳。 我可以单独提供文件,但它带有我不想要的时间戳。原因是我希望其他站点能够访问此文件。
代码如下:
application.html.erb
<%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
<%= javascript_include_tag 'ca4me', 'data-turbolinks-track' => true, :cache => false %>
应用程序.js
// This is a manifest file that'll be compiled into application.js, which will include all the files
// listed below.
//
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
//
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// compiled file.
//
// Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
// about supported directives.
//
//= require jquery
//= require jquery_ujs
//= require turbolinks
//= require bootstrap-slider
//= require bootstrap.min
应用程序.rb
config.assets.precompile += %w( ca4me.js )
生产环境中的 HTML 源代码:
<script data-turbolinks-track="true" src="/assets/application-b83af88604eb0fb1867384db77b826ae.js"></script>
<script cache="false" data-turbolinks-track="true" src="/assets/ca4me-fcff49d8b1799052a3f84c913160f6b2.js"></script>
那么我可以在没有时间戳的情况下提供 ca4me.js 吗?
【问题讨论】:
-
将其放入
/public/,而不是资产管道中。
标签: ruby-on-rails heroku asset-pipeline