Rails 4 - NO manifest.json after assets precompile on production server

5k views Asked by At

Here is the app/assets/ for a Rails 4.2 app.

enter image description here

There are 3 bootstraps js and css files. After deploying to production (ubuntu 12.1), assets precompile was done on server (deployed under suburi):

RAILS_ENV=production bundle exec rake assets:precompile RAILS_RELATIVE_URL_ROOT=/mysuburi

Here is the 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

Here is the head of application.css.scss:

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

@import "simple_form.css.scss";
@import "user_menus.css.scss";

In application.js, it has:

//= require bootstrap.min

Here is the output of ls for public/assets/ on production server:

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

By comparing with other Rails app, it is missing manifest.json under /assets. We tried various config options in config/environment/production.rb with no avail. The only option works on production server is live compilation of config.assets.compile = true (not recommended). What is wrong with our code to cause assets precompile failing?

UPDATE: we have re-built the Rails app from ground up and the assets problem remains the same. This assets precompile issue may have nothing to do with setup in config/production.rb' and 'config/initializers/aseets.rb as we suspect. Rolling back version of bundler and rake did not help. The same bootstrap css and js files have been used in another Rails 4.2 app running on the same production server without the problem.

3

There are 3 answers

1
Kent Dahl On

I presume you include these JS and CSS files in your application HTML template explicitly?

They won't magically end up compiled into the main application CSS and JS file, and you need to make sure that you use the tag helpers, not direct paths, when referencing them from HTML erb files.

When in doubt, use asset_path.

0
user938363 On

The manifestxxx.json file is generated after rolling back version of sprockets to 2.12.3 from 3.2.0. The problem was caused by too-new version of gem sprockets which is used to precompile assets.

1
rkrdo On

If you're using sprockets 3.x, the manifest file is now named .sprockets-manifest-md5hash.json, it is stated in the Upgrading Guide