无法将SASS编译成CSS,但映射看起来不错



我在终端中全局安装了sass。npm install sass -g。我在源文件夹中有一个sass文件$grey: #444; $red: rgb(250, 0, 0);将sass从源文件夹编译到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文件输出。我需要一些指针。

我已经使用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.

相关内容

最新更新