简体   繁体   中英

Why Rails Asset Pipeline uses require instead of @import?

If Rails (3, 4) uses SASS for precompile the CSS, Why uses "require" for default, instead of Sass directive "@import" ( http://sass-lang.com/documentation/file.SASS_REFERENCE.html#import )

The same Rails documentation suggest to use "@import" ( http://edgeguides.rubyonrails.org/asset_pipeline.html )

As noted in the document you linked to , @import is preferable because Sass variables can be shared between files. But having the Sprockets-provided require directive allows you to include stylesheets from gems or bypass using Sass altogether.

There is usually more than one way to accomplish a task, it's good to have options. For instance, Javascript has many solutions to dependency management, but the simple Sprockets require is often adequate for simple applications.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM