Rails / Sass: import a file from a vendor folder

I have a stylesheet app/assets/website/base.scss that starts with:

 @import "bootstrap-select.min.css"; 

The bootstrap-select.min.css exists in the vendor/stylesheets/ folder. When I try to access it during production, I get 404:

"NetworkError: 404 Not Found - http://mysite.herokuapp.com/assets/bootstrap-select.min.css "

(It works great on my development platform.)

Here is what I have tried so far:

  • Tried to use @import asset-path("bootstrap-select.min.css") . Got a syntax error (apparently asset-path does not work with import s).

  • I tried adding config.assets.precompile += %w(bootstrap-select.min.css) to config/environments/production.rb

Any idea why this could be happening?

Rails 4.0.4 / Ruby 2.1.2

+6
source share
2 answers

Finished changing it from bootstrap-select.min.css bootstrap-select.min.scss ..

It worked!

Sass actually .scss contents of the .scss files in place - with .css files it just refers to the file with @import , so it doesn't work (thanks @cimmanon!)

+5
source

In fact, you can simply remove the .css suffix from @import "bootstrap-select.min.css"; Sass expects from you only the name of the assets and is smart enough to look at all possible placements of assets and import everything that it can import (so the name should be format-independent)

+2
source

Source: https://habr.com/ru/post/973456/


All Articles