为什么Heroku在生产中加载更少的css js?

时间:2013-07-10 10:39:30

标签: ruby-on-rails heroku ruby-on-rails-4

以下是Heroku制作的页面源标题:

<head>
  <title>Gosgf</title>
  <link data-turbolinks-track="true" href="/assets/application-e11c07d8fd96415a6de17e941d115bde.css" media="all" rel="stylesheet" />
  <script data-turbolinks-track="true" src="/assets/application-786dea1c8b4a7b9d1635fb121196a3f3.js"></script>
  <meta content="authenticity_token" name="csrf-param" />
  <meta content="LAzUNgZEUmay9OLVUsN0u6Amz/9BVJngJKvE+B6+L1g=" name="csrf-token" />
</head>

这是从127.0.0.1:3000

<head>
  <title>Gosgf</title>
  <link data-turbolinks-track="true" href="/assets/application.css?body=1" media="all" rel="stylesheet" />
<link data-turbolinks-track="true" href="/assets/games.css?body=1" media="all" rel="stylesheet" />
<link data-turbolinks-track="true" href="/assets/jgo/jgoboard.css?body=1" media="all" rel="stylesheet" />
<link data-turbolinks-track="true" href="/assets/jgo/jgoboard_small.css?body=1" media="all" rel="stylesheet" />
<link data-turbolinks-track="true" href="/assets/sgfs.css?body=1" media="all" rel="stylesheet" />
<link data-turbolinks-track="true" href="/assets/welcome.css?body=1" media="all" rel="stylesheet" />
  <script data-turbolinks-track="true" src="/assets/jquery.js?body=1"></script>
<script data-turbolinks-track="true" src="/assets/jquery_ujs.js?body=1"></script>
<script data-turbolinks-track="true" src="/assets/turbolinks.js?body=1"></script>
<script data-turbolinks-track="true" src="/assets/games.js?body=1"></script>
<script data-turbolinks-track="true" src="/assets/jgo/all-min.js?body=1"></script>
<script data-turbolinks-track="true" src="/assets/jgo/autodiv.js?body=1"></script>
<script data-turbolinks-track="true" src="/assets/jgo/jgoboard.js?body=1"></script>
<script data-turbolinks-track="true" src="/assets/jgo/sgf.js?body=1"></script>
<script data-turbolinks-track="true" src="/assets/jquery/jquery-1.10.1.js?body=1"></script>
<script data-turbolinks-track="true" src="/assets/jquery/jquery-1.10.1.min.js?body=1"></script>
<script data-turbolinks-track="true" src="/assets/jquery/jquery.min.js?body=1"></script>
<script data-turbolinks-track="true" src="/assets/sgfs.js?body=1"></script>
<script data-turbolinks-track="true" src="/assets/welcome.js?body=1"></script>
<script data-turbolinks-track="true" src="/assets/application.js?body=1"></script>
  <meta content="authenticity_token" name="csrf-param" />
  <meta content="8+ZHwU8R9V/V5zgoVL3fqyGKxYG2BxV2f8LtRCZNDAg=" name="csrf-token" />
</head>

Heroku会忽略js下的cssapp/asserts

我已添加:

 gem 'rails_12factor', group: :production

在Gemfile中。

预编译资产:

 RAILS_ENV=production bundle exec rake assets:precompile
 git add public/assets
 git commit -m "compiled assets"
push之前

config/environments/production.rb

 config.serve_static_assets = true
 config.assets.compile = true

如何告诉Heroku加载jscss资产?

1 个答案:

答案 0 :(得分:2)

这是正常的 - 您的生产页面加载的application.js和application.css应该包含您的所有应用程序的资产(至少包含application.css或application.js清单所包含的内容)。

这是(除其他事项外)预编译的作用。