Question

Since my production machine is somewhat limited (raspberry pi), I want to install as few gems as possible in my production machine. In order to reduce the dependencies, I want to do the precompiling of my assets on my dev machine and deploy them to production. So I don't have to do the precompilition on my production machine and don't need all the gems which are required by the asset pipeline.

So I've moved all gems in the Gemfile to the assets group and changed my config/application.rb:

Bundler.require *Rails.groups(:assets => %w(development test))

In development and test environment everything works fine.

But if I want to do the precompilation on my dev machine via ...

RAILS_ENV='production' bundle exec rake assets:precompile

... it breaks due the gems from the assets group are missing.

But I can't simply add the assets group to production environment, since that would require to install all the assets gems in my production environment (what I don't want to do).

Does someone have an idea how to solve that?

Was it helpful?

Solution

You can compile it rake assets:precompile in dev m/c and then commit the public/assets folder to remote repo. So when the production server is started it will take the already precompiled assets from the assets folder. Make sure any js/css/image change you do, update the assets file accordingly.

Any gem mentioned in Gemfile has to be installed. In case you don't feel the need to use specific gems, remove it from Gemfile. ex. rubyracer gem is present in Gemfile which is used for compiling js. To avoid any issues, fallback in case compiled asset is not present should be false as compiling on runtime will not be possible due to absence of js compilers

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top