Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails / Sass: Import file from the vendor folder

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:

  1. Tried using @import asset-path("bootstrap-select.min.css"). Got a syntax error (apparently asset-path doesn't work with imports).

  2. 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

like image 848
FloatingRock Avatar asked Aug 06 '14 20:08

FloatingRock


People also ask

How do I import a SCSS file into rails?

You can just add the import to the application. scss file so it will look like: @import "bootstrap/bootstrap.

Which directive is used to import files in sass?

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.

How does Sass import work?

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.


1 Answers

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!)

like image 113
FloatingRock Avatar answered Sep 20 '22 14:09

FloatingRock