Rails: disadvantages of using Sass @import instead of * = require

I decided to use Sass @importinstead of Sprocket *=require.

I have this in application.scss :

@import 'normalize';
@import 'font-awesome';
@import 'variables';

and this is in blog.scss :

@import 'application';

Thus, I have separate stylesheets for individual controllers (makes my code more organized).

To make this work, I also added stylesheet_link_tag params[:controller]to my layout, then added a line Rails.application.config.assets.precompile += %w( blog.css )to the /config/initializers/assets.rb file and restarted the server.

Is there a drawback to this approach? Will turbines be slower?

+6
source share
3 answers

Rails Asset Pipeline Sass @import Sprockets * = require, Sass.

Rails Asset Pipeline:

" Sass, , , Sass @import Sprockets. Sprockets Sass , , (http://guides.rubyonrails.org/asset_pipeline.html) "

Github sass-rails (https://github.com/rails/sass-rails). :

"Sprockets , , require, require_tree require_self. SASS/SCSS-. Sass. Sass native @import , sass-rails Rails-. "

, (, ):

  1. , SASS @import , Sprockets - .

  2. , , @imports .

  3. @import Whorfian, , ( ), . , z- , (https://content.pivotal.io/blog/structure-your-sass-files-with-import).

+6

Sass @imports , Sprockets. , , . , Sprockets , , . , , @import , . treehouse:

http://blog.teamtreehouse.com/tale-front-end-sanity-beware-sass-import

+1

, HTTP-, , , - sass :

Sass is built on top of the current @import CSS, but instead of requesting an HTTP request, Sass will take the file you want to import and combine it with the imported file so that you can serve one CSS file to a web browser.

0
source

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


All Articles