简体   繁体   中英

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: 在此处输入图片说明

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?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM