Import regular CSS file in SCSS file?

后端 未结 13 1629
旧巷少年郎
旧巷少年郎 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:49

    If you have a .css file which you don't wish to modify, neither change its extension to .scss (e.g. this file is from a forked project you don't maintain), you can always create a symlink and then import it into your .scss.

    Creates a symlink:

    ln -s path/to/css/file.css path/to/sass/files/_file.scss
    


    Imports symlink file into a target .scss:

    @import "path/to/sass/files/file";
    


    Your target output .css file is going to hold contents from imported symlink .scss file, not a CSS import rule (mentioned by @yaz with highest comment votes). And you don't have duplicated files with different extensions, what means any update made inside initial .css file immediately gets imported into your target output.

    Symbolic link (also symlink or soft link) is a special type of file that contains a reference to another file in the form of an absolute or relative path and that affects pathname resolution.
    – http://en.wikipedia.org/wiki/Symbolic_link

提交回复
热议问题