6

I'm trying to deploy my rails app to heroku using this turtorial:

https://devcenter.heroku.com/articles/getting-started-with-rails4

So, I use rails 4.1.1 and ruby 2.1.1

My Gemfile has gem 'rails_12factor', group: :production inside.

My application.rb:


require File.expand_path('../boot', __FILE__)

require 'rails/all'

Bundler.require(*Rails.groups)

module Charticus
  class Application  Rails::Application
    # Settings in config/environments/* take precedence over those specified here.
    # Application configuration should go into files in config/initializers
    # -- all .rb files in that directory are automatically loaded.

    # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
    # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
    # config.time_zone = 'Central Time (US & Canada)'

    # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
    # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
    # config.i18n.default_locale = :de
  end
end

I created file public/assets/manifest.yml

But when I deploy app to heroku - it compile all my js-files files to application.js and all css-files application.css. And I can't see it on app.heroku.com using firebug.

What I need to do with my configurations to see all my js and css files on app.heroku.com ? How disable assets precompiling and minification on heroku?

Help me please! Thanks

5 Answers 5

11

lib/tasks/assets.rake

Rake::Task["assets:precompile"].clear
   namespace :assets do
     task 'precompile' do
     puts "Not pre-compiling assets..."
   end
end

You are done.

1
  • In my case I had to write it on Rakefile. Apr 6, 2020 at 10:18
3

I compare config/environments/development.rb and config/environments/production.rb.

And make production.rb asset configs like in development.rb:

Comment this lines:

  • config.serve_static_assets = false
  • config.assets.js_compressor = :uglifier
  • config.assets.compile = false
  • config.assets.digest = true

Then:

  1. Push my changes to git repo git push origin master
  2. Push changes to heroku git push heroku master
2
  • I had to add the setting config.assets.debug = true as well. Jul 28, 2014 at 18:22
  • This doesn't prevent Heroku's Ruby buildpack from calling the rake assets:precompile rake task. It just configures the production environment to be like the development environment. Mar 20, 2018 at 18:49
0

Rails 4 applications have a manifest-*.json file, not a manifest.yml file. This file is typically generated when you run rake assets:precompile , how are you compiling your assets?

Regardless, you need a file public/assets/manifest-(fingerprint).json file

2
  • I create public/assets/manifest-(fingerprint).json, and now heroku app cannot find application.css and application.js ...
    – bmalets
    May 15, 2014 at 21:53
  • 1
    what are you trying to do? Are you running asset compilation locally? Then manifest file is created for you. It's not just a blank file...
    – catsby
    May 16, 2014 at 20:06
0

Fast forward to 2018, and you would need to add the following to config/initializers/production.rb:

config.assets.enabled = false

Then you'd need to customize Heroku's Ruby Buildpack to not run the assets:precompile rake task. I won't provide a link to such a buildpack because I won't support or warrant one, but its pretty easy to find it in lib/language_pack/ruby.rb and start removing relevant code.

You'd then have to configure your Heroku app to use your new forked Buildpack instead of the default one (e.g. using heroku buildpacks).

Thats the cleanest way to disable the asset pipeline in a Heroku app w/ Rails, without resorting to overriding Rails' built-in rake tasks.

0

Fast forward to 2021 and Rails 6.x, if you completely removed Webpacker and Sprockets/Asset Pipeline, replace the bin/yarn file content with something like:

#!/usr/bin/env ruby
puts 'Yarn not present, nothing to do.'

@danielricecodes's advice is probably still valid but way more invasive.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.