Import regular CSS file in SCSS file?

后端 未结 13 1642
旧巷少年郎
旧巷少年郎 2020-11-22 06:19

Is there anyway to import a regular CSS file with Sass\'s @import command? While I\'m not using all of the SCSS syntax from sass, I do still enjoy it\'s combini

13条回答
  •  甜味超标
    2020-11-22 06:42

    This was implemented and merged starting from version 3.2 (pull #754 merged on 2 Jan 2015 for libsass, issues originaly were defined here: sass#193 #556, libsass#318).

    To cut the long story short, the syntax in next:

    1. to import (include) the raw CSS-file

      the syntax is without .css extension at the end (results in actual read of partial s[ac]ss|css and include of it inline to SCSS/SASS):

      @import "path/to/file";

    2. to import the CSS-file in a traditional way

      syntax goes in traditional way, with .css extension at the end (results to @import url("path/to/file.css"); in your compiled CSS):

      @import "path/to/file.css";

    And it is damn good: this syntax is elegant and laconic, plus backward compatible! It works excellently with libsass and node-sass.

    __

    To avoid further speculations in comments, writing this explicitly: Ruby based Sass still has this feature unimplemented after 7 years of discussions. By the time of writing this answer, it's promised that in 4.0 there will be a simple way to accomplish this, probably with the help of @use. It seems there will be an implementation very soon, the new "planned" "Proposal Accepted" tag was assigned for the issue #556 and the new @use feature.

    answer might be updated, as soon as something changes.

提交回复
热议问题