【问题标题】:cannot Compile SASS into CSS but mapping looks alright无法将 SASS 编译成 CSS,但映射看起来没问题
【发布时间】:2021-08-02 02:27:35
【问题描述】:

我在终端中全局安装了 sass。 npm install sass -g。我在源文件夹中有一个 sass 文件 $grey: #444; $red: rgb(250, 0, 0); 将 sass 从源文件夹编译成 css 到 css 文件夹。我输入:

@sass --watch source/style.scss css/style.css 终端中的结果: comile sass

css文件夹中生成的style.css.map和style.css。 结果是 style.css.map 有输出 {"version":3,"sourceRoot":"","sources":[],"names":[],"mappings":"","file":"style.css"} 并且 style.css 中的输出有

/*# sourceMappingURL=style.css.map */

。 所以,我可以看到映射看起来不错。但是我的 css 文件输出在哪里。我需要一些指针。

【问题讨论】:

    标签: sass


    【解决方案1】:

    我已经使用npm install sass -g 全局安装了 sass,并且正在编译 使用@sass --watch source/style.scss css/style.css 的 sass 文件。 sass 文件声明变量 $grey: #444; $red: rgb(250, 0, 0); 没问题。我错过的一件事是在 sass --watch 命令的参数之间添加一个冒号 (:),例如 @sass --watch source/style.css:css/style.css ,如果它只是文件,则通常不需要。

    当我编译文件时,它在文件夹 css 中生成了文件 style.css。 显示了 mappingURL 输出,因为我没有使用这些变量。我后来添加为:

    body {
     margin: 0;
     padding: 0;
     background-color: $grey;
     color: $red;
    }
    ```.  
    Then then css file was compiling sass file to css. That was it.
    
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2022-08-19
      • 1970-01-01
      • 1970-01-01
      • 2017-11-02
      • 2015-07-30
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多