首页 文章

终端中的sass和scss命令有什么区别

提问于
浏览
1

在我安装Sass ruby gem之后,系统中添加了三个新命令: sassscsssass-convert . 所以,我的问题是 sassscss 命令之间的区别是,它们是否共享相同的功能?因为它们都可以将.sass文件或.scss文件转换为.css文件:

$ sass style.sass style.css
$ sass style.scss style.css
$ scss style.sass style.css
$ scss style.scss style.css

所有这四种指令都可以正确运行 .

PS:我不是要问SCSS语法和Sass语法之间的区别 .

3 回答

  • 0

    在你的命令上使用 --help 标志会给你答案:

    SASS-转换:

    $ sass-convert --help
    Usage: sass-convert [options] [INPUT] [OUTPUT]
    
    Description:
      Converts between CSS, Sass, and SCSS files.
      E.g. converts from SCSS to Sass,
      or converts from CSS to SCSS (adding appropriate nesting).
    

    SCSS:

    $ scss --help
    Usage: scss [options] [INPUT] [OUTPUT]
    
    Description:
      Converts SCSS or Sass files to CSS.
    

    青菜:

    $ sass --help
    Usage: sass [options] [INPUT] [OUTPUT]
    
    Description:
      Converts SCSS or Sass files to CSS.
    
  • -1

    命令 scss 等同于 sass --scss ,其中命令 sass 等同于 scss --sass . 这两个命令(例如两个选项)对syntax selection使用不同的默认语法 .

    首先, scsssass 都会根据您的文件扩展名解析语法 . ( scss 将使用sass语法解析器,如果你的文件扩展名是sass,反之亦然 . )在这种情况下它们会表现相同,这就是你得到正确结果的原因 .

    但是,如果您的文件没有文件扩展名 . 该命令将使用默认语法解析语法 . 例如,以下代码将为您提供正确的结果,因为它使用sass语法分析器 .

    $ scss style.sass style.css
    

    以下代码可能会给您一个解析错误,因为它使用scss语法解析器 .

    $ scss style_sass.txt style.css
    
  • 0

    Sass是一个具有语法改进的CSS预处理器 . 高级语法中的样式表由程序处理,并转换为常规CSS样式表 . 但是,它们并没有扩展CSS标准本身 .

    其主要原因是增加了CSS痛苦缺乏的功能(如变量) .

    重新考虑SCSS和Sass之间的区别,Sass home page上的文字应该回答这个问题:

    Sass is an extension of CSS3, adding nested rules, variables, mixins, selector inheritance, and more. It’s translated to well-formatted, standard CSS using the command line tool or a web-framework plugin.

    Sass has two syntaxes. The new main syntax (as of Sass 3) is known as “SCSS” (for “Sassy CSS”), and is a superset of CSS3’s syntax. This means that every valid CSS3 stylesheet is valid SCSS as well. SCSS files use the extension .scss.

    The second, older syntax is known as the indented syntax (or just “Sass”). Inspired by Haml’s terseness, it’s intended for people who prefer conciseness over similarity to CSS. Instead of brackets and semicolons, it uses the indentation of lines to specify blocks. Although no longer the primary syntax, the indented syntax will continue to be supported. Files in the indented syntax use the extension .sass.

    但是,所有这些只适用于最终创建CSS的Sass预编译器 . 它不是CSS标准本身的扩展 .

相关问题