Steven Aguilar
Steven Aguilar

Reputation: 3049

How to precompile assets using wildcard on a rails 4.2.6 application

I'm currently working on a Rails 4.2.6 application. In the styles sheet folder I have sub directories that represents part of the the application, as shown in the image below: enter image description here

In the config/initializers/assets.rb file I have the following code:

# Precompile additional assets.
# application.js, application.css, and all non-JS/CSS in app/assets folder are already added.
# Rails.application.config.assets.precompile += %w( search.js )
Rails.application.config.assets.precompile += %w( faq_page/faq.css )
Rails.application.config.assets.precompile += %w( contact/new.css )

I have to add each file in order to precompile the assets. I tried using the following code config.assets.precompile = ['*.js', '*.css'] but it didn't work. I get the following error

Sass::SyntaxError in Pages#home

How can I precompile the assets with a wildcard without having to add each .css file to assets.rb?

Upvotes: 0

Views: 907

Answers (1)

NM Pennypacker
NM Pennypacker

Reputation: 6952

Everything in your /assets folder should automatically be included in the asset pipeline. You should be able to remove config.assets.precompile = ['*.js', '*.css'] from your assets initializer altogether.

The only time you should have to add to config.assets.precompile is when you want to add assets from a directory such as /vendor

Upvotes: 1

Related Questions