Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Require statement in application.css.scss

I want to use a lightbox gem such as fancybox or color box. Both gems ask to add this line in the application.css

 *= require colorbox-rails 

Here's the problem. I only have application.css.scss files. All my css files are scss files. I have import statements in the application.css.scss but no *=require statements. Adding the above line results in the error :

Invalid CSS after "*": expected "{", was "=require colorb..."

Here's the complete application.css.scss

@import "bootstrap"; @import "welcome"; @import "sessions"; @import "users";   *= require colorbox-rails 
like image 683
user2511030 Avatar asked Oct 02 '14 23:10

user2511030


People also ask

Can I use SCSS in CSS file?

scss is the source file and style. css is the destination file where Sass generates the CSS code. Now installation and configuration are complete! You can use Sass in your projects.

Is it better to use CSS or SCSS?

When it comes to the domain of styling web pages, we have the choice of using plain CSS or SCSS in a project (among other preprocessors). SCSS is a superset of CSS. Most developers find it more convenient to use it over CSS due to its advanced features and clearer syntax.

Can browsers read SCSS?

Unfortunately, the features of SCSS have yet to be introduced in the CSS specs and, therefore, are not supported by browsers. To run SCSS code in a web browser, you must first convert it to CSS.


1 Answers

application.css.scss or application.css are kinda the same. Just rename your application.css to application.css.scss.

As for adding that line, it'll need to be right up the top, in a comment. Like this:

/*  * This is a manifest file that'll be compiled into application.css, which will include all the files  * listed below.  *  * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,  * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.  *  * You're free to add application-wide styles to this file and they'll appear at the bottom of the  * compiled file so the styles you add here take precedence over styles defined in any styles  * defined in the other CSS/SCSS files in this directory. It is generally better to create a new  * file per style scope.  *  *= require_self  *= require colorbox-rails  */  @import "bootstrap"; @import "welcome"; @import "sessions"; @import "users"; 
like image 88
joshua.paling Avatar answered Sep 28 '22 03:09

joshua.paling