看documentation for render_with_sourcemap後(不幸的是無法找到任何示例的這一使用),我的印象,下面應該工作:如何使用薩斯:: Engine的render_with_sourcemap
@source_dir = './sass/'
@target_dir = './css/'
@output = Sass::Engine.new(File.read(@source_dir + 'style.scss'), {
cache_location: @source_dir + '.sass-cache',
style: :compressed,
syntax: :scss
}).render_with_sourcemap(@target_dir + 'style.css.map')
然而,錯誤我得到的是:
Error generating source map: couldn't determine public URL for the source stylesheet. (Sass::SyntaxError)
No filename is available so there's nothing for the source map to link to.
它的工作原理簡單地使用呈現(它不需要參數),而不是render_with_sourcemap,所以我導致相信我的文件名是錯誤的 - 但是,我沒有看到我做錯了什麼。我也嘗試/style.css.map
,./style.css.map
和@target_dir + style.css.map
,都沒有成功(得到相同的錯誤)