如何在不创建地图文件的情况下编译sass/scss

Wil*_*low 8 css command-line compilation sass

我去寻找这个答案,发现它还没有在Stack Overflow上.所以我希望能为有需要的人分享这些知识.

情况:

在命令行中:将压缩的SASS文件从scss文件夹编译到css文件夹中.

sass --watch scss:css --style compressed

这会创建css文件,但它也会创建.map文件.

题:

那么如何阻止创建这些.map文件呢?

Wil*_*low 19

回答:

添加--sourcemap=none到您的命令.

所以它看起来像:

sass --watch scss:css --style compressed --sourcemap=none

  • @William,你的意思是地图文件有什么影响? (2认同)
  • 我删除了它们,因为它们太多了,它们会导致与 git 发生冲突。以下是有关他们所做工作的更多信息:http://thesassway.com/intermediate/using-source-maps-with-sass (2认同)
  • 这个答案不再有效,请参阅下面 sh78 的答案。(我认为你也应该在你的回答中提到这一点) (2认同)

sh7*_*h78 6

2019 年更新

运行--sourcemap-none于最新版本sass(1.21.0)返回Could not find an option named "sourcemap".

新标志是--no-source-map.

??? Source Maps ????????????????????????
--[no-]source-map          Whether to generate source maps.
                           (defaults to on)

--source-map-urls          How to link from source maps to source files.
                           [relative (default), absolute]

--[no-]embed-sources       Embed source file contents in source maps.
--[no-]embed-source-map    Embed source map contents in CSS.
Run Code Online (Sandbox Code Playgroud)

此外,sass 是众多具有内置帮助输出的 CLI 程序之一。sass不带任何参数运行会显示使用说明和各种标志,如下所示。