I have a stylesheet app/assets/website/base.scss
that starts with:
@import "bootstrap-select.min.css";
The bootstrap-select.min.css
file exists in the vendor/stylesheets/
folder. When I try to access it in production, I get a 404:
"NetworkError: 404 Not Found - http://mysite.herokuapp.com/assets/bootstrap-select.min.css"
(It works fine on my development rig though.)
Here's what I've tried so far:
Tried using @import asset-path("bootstrap-select.min.css")
. Got a syntax error (apparently asset-path
doesn't work with import
s).
Tried adding config.assets.precompile += %w(bootstrap-select.min.css)
to config/environments/production.rb
Any idea why this might be happening?
Rails 4.0.4 / Ruby 2.1.2
You can just add the import to the application. scss file so it will look like: @import "bootstrap/bootstrap.
Sass Importing Files Just like CSS, Sass also supports the @import directive. The @import directive allows you to include the content of one file in another.
When Sass imports a file, that file is evaluated as though its contents appeared directly in place of the @import . Any mixins, functions, and variables from the imported file are made available, and all its CSS is included at the exact point where the @import was written.
Ended up changing it from bootstrap-select.min.css
--> bootstrap-select.min.scss
..
It worked!
Sass actually places the contents of .scss
files in place - With .css
files it just links to the file with an @import
, which is why it wasn't working (thanks @cimmanon!)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With