Setting Vendor Assets Precompile in Rails 4

Often times you'll need to use some kind of vendor specific files for your Ruby on Rails project. These files can be part of CSS/JavaScript template you use for your project. They can't be stored in your app/assets folder due to pre-processing or CSS files, so it is best to store these files under vendor specific folder. In order to configure assets paths to these files you need to include the following Ruby on Rails  lines of code to your config/application.rb file

config.assets.paths << Rails.root.join('vendor', 'assets', 'stylesheets')
config.assets.paths << Rails.root.join('vendor', 'assets', 'javascript')

config.assets.paths << Rails.root.join('vendor', 'assets', 'fonts')
config.assets.precompile += %w( .svg .eot .woff .ttf)
config.assets.precompile += %w(*.png *.jpg *.jpeg *.gif)

You can see from the example above that we are adding CSS/JavaScript/Fonts to our project. The main reason you need to do that is Rails 4 does not automatically includes these files from locations such as /vendor/ or /lib/ so you need to direct yourself to add these lines of code. Here is a little bit more info on why this is so: https://github.com/rails/rails/pull/7968 

Featured pages

Ruby

Set of Ruby Object Oriented Programming Language tutorials that cover such topics as Ruby strings, …

Rails

Rails Framework tutorial teaches you how to utilize de facto framework of choice for Ruby developme…

Ruby Duck Typing

“If an object quacks like a duck just go ahead and treat it as a duck” – this fun…

Regular Expressions

Ruby uses the =~ operator to check any given string against regular expression. For example, a stri…

Credit Card Number

Every last digit of any credit card is a check sum digit that is determined by all digits in front …

Ruby Arrays

Ruby Programming Language has built in support for Arrays. Arrays help you define some of the compl…

Ruby Hashes

Hashes are very similar to arrays in Ruby and hashes interface is similar to Ruby array interface. …

Ruby Code Block

Ruby is very unique language when it comes to code blocks. You can simply pass a code block to a me…