11

Compass 是否支持 Sass 中的 --sourcemap 选项?我想通过 Compass 运行 Sass。我有

sass_options = {:sourcemap => true}

在我的 config.rb 中,但是当我compass watch在我的项目文件夹中运行时,没有生成源映射文件。另一方面,当我跑步时

sass --compass --sourcemap --watch scss:css

生成源文件,但忽略 config.rb。

(对于任何想知道 sourcemap 是什么的人,它是一个文件,当您检查元素时,它允许开发人员工具检查器指向 Sass scss 文件中样式的来源。)

4

3 回答 3

13

@cimmanon 提供的解决方案对我不起作用。对我有用的是以下内容(感谢 Serge-Z 在https://github.com/Compass/compass/issues/1108):

sudo gem install compass-sourcemaps --pre

然后你就像compass watch往常一样sass_options = {:sourcemap => true}在你的 config.rb 中做。

如果您在 OS X El Capitan 上并且由于无根模式而无法安装(感谢 Thomzzzzz 在https://github.com/Compass/compass/issues/2018中):

sudo gem install -n /usr/local/bin compass-sourcemaps --pre
于 2013-11-29T13:17:59.540 回答
12

从 Sass 3.3 或更高版本开始包含源映射,它仅与 Compass 1.0 兼容。

https://github.com/chriseppstein/compass/issues/1108

将以下内容添加到您的 config.rb 只会将 sourcemap 信息直接添加到您编译的 CSS 中:

sass_options = { :debug_info => true }

输出:

@media -sass-debug-info{filename{font-family:file\:\/\/\/home\/chris\/compass\/sass\/test\.scss}line{font-family:\0000314}}
.foo {
  color: red;
}

要获取源映射文件,您需要将此选项添加到 config.rb:

sourcemap = true

控制台输出:

$ compass watch
 modified config.rb
    clean css
   delete css/test.css
>>> Compass is watching for changes. Press Ctrl-C to Stop.
    write css/test.css
    write css/test.css.map
于 2013-04-19T14:39:58.703 回答
2

对我来说,它适用于

sourcemap = true

在 config.rb 中(解决方案取自https://chillco.com/blog/setting-sass-and-compass-source-maps

我通过考拉使用指南针(http://koala-app.com/

于 2014-12-23T23:29:11.180 回答