Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails Engine assests are not precompiled

I am studying rails and using the engines with rails. In production mode, rails did not load compiled assets of engines, although I have executed:

$ RAILS_ENV=production bundle exec rake assets:clean assets:precompile

Please help if anyone knows the issue.

My settings are as below:

environment/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 
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`

engine/xxx/lib/xxx/engine.rb

Engines's option is -- mountable

 module Moderna  
  class Engine < ::Rails::Engine  
    isolate_namespace xxx

    # parent company asset precompile
    initializer "xxx.assets.precompile" do |app|

      app.config.assets.paths << Rails.root.join("app", "assets", "fonts")

      app.config.assets.precompile << %w(
        xxx/*.css xxx/fancybox/*.css xxx/skin/*.css xxx/google-code-prettify/*.css
        xxx/*.js xxx/flexslider/*.js xxx/google-code-prettify/*.js
        xxx/portfolio/*.js xxx/quicksand/*.js
        xxx/*.svg xxx/*.eot xxx/*.woff xxx/*.ttf
        xxx/customicon/*.svg xxx/customicon/*.eot xxx/customicon/*.woff xxx/customicon/*.ttf
      )

      app.config.assets.precompile << /\.(?:svg|eot|woff|ttf)\z/
    end
  end
end
like image 344
yongwoon Avatar asked Mar 14 '16 14:03

yongwoon


1 Answers

The rails engine getting started guide suggests including the following in your engine.rb

initializer "engine_name.assets.precompile" do |app|
  app.config.assets.precompile += %w( admin.js admin.css )
end

It works for me.

like image 60
Tad Avatar answered Sep 25 '22 15:09

Tad