Rails 4 - 在生产服务器上资源预编译之后没有manifest.json

use*_*363 15 ruby-on-rails precompile asset-pipeline ruby-on-rails-4

这是Rails 4.2应用程序的app/assets /.

在此输入图像描述

有3个bootstraps js和css文件.部署到生产(ubuntu 12.1)后,资产预编译在服务器上完成(部署在suburi下):

RAILS_ENV=production bundle exec rake assets:precompile RAILS_RELATIVE_URL_ROOT=/mysuburi
Run Code Online (Sandbox Code Playgroud)

这是production.rb:

  config.cache_classes = true
  config.eager_load = true
  config.consider_all_requests_local       = false
  config.action_controller.perform_caching = true
  config.serve_static_files = false #ENV['RAILS_SERVE_STATIC_FILES'].present?
  config.assets.compress = true
  config.assets.js_compressor = :uglifier
  config.assets.compile = false
  config.assets.digest = true
  config.log_level = :debug
  config.i18n.fallbacks = true
  config.active_support.deprecation = :notify
  config.log_formatter = ::Logger::Formatter.new
  config.active_record.dump_schema_after_migration = false
Run Code Online (Sandbox Code Playgroud)

以下是负责人application.css.scss:

@import "bootstrap.min.css";
@import "bootstrap-theme.min.css";

@import "simple_form.css.scss";
@import "user_menus.css.scss";
Run Code Online (Sandbox Code Playgroud)

application.js,它有:

//= require bootstrap.min
Run Code Online (Sandbox Code Playgroud)

以下是lspublic/assets/on production服务器的输出:

application-05cf37813d76c2bd659271403789374cc118f1a4e616ec220969577b79ff6514.css
application-375b4b5d8fc285716f4fdca966aa960912efe8292242df8f1a60b99d5caa4b02.js
authentify
banquet_coursex
banquetx
biz_workflowx
commonx
glyphicons-halflings-regular-5d234508037dc13a419ef6ce48f3fc73dbb477f1a162c052b872182b494e626e.svg
glyphicons-halflings-regular-bd18efd3efd70fec8ad09611a20cdbf99440b2c1d40085c29be036f891d65358.ttf
glyphicons-halflings-regular-f495f34e4f177cf0115af995bbbfeb3fcabc88502876e76fc51a4ab439bc8431.eot
glyphicons-halflings-regular-fc969dc1c6ff531abcf368089dcbaf5775133b0626ff56b52301a059fc0f9e1e.woff
jquery-ui
searchx
state_machine_logx
user_manualx
user_menus-7c46e17f4172c2a954eeaf85e80b4e030d1ed0fb3927288bbe07eeb4fb8cbfc5.css
Run Code Online (Sandbox Code Playgroud)

通过与其他Rails应用程序进行比较,它manifest.json在/ assets下缺失.我们尝试了各种配置选项config/environment/production.rb但无济于事.生产服务器上唯一可行的选项是实时编译config.assets.compile = true(不推荐).我们的代码导致资产预编译失败的问题是什么?

更新:我们已经从头开始重新构建了Rails应用程序,资产问题仍然存在.这个资产预编译问题可能与config/production.rb' and 'config/initializers/aseets.rb我们怀疑的设置无关.回滚的版本bundler,并rake没有帮助.相同的bootstrap css和js文件已经在同一个生产服务器上运行的另一个Rails 4.2应用程序中使用而没有问题.

rkr*_*rdo 17

如果您正在使用sprockets 3.x,则清单文件现在已命名.sprockets-manifest-md5hash.json,它在" 升级指南"中说明


小智 0

我假设您在应用程序 HTML 模板中明确包含这些 JS 和 CSS 文件?

它们不会神奇地最终编译到主应用程序 CSS 和 JS 文件中,并且您需要确保在从 HTML erb 文件引用它们时使用标签助手,而不是直接路径。

如有疑问,请使用 asset_path。