英语
外观
Stylus 根据 Sourcemap v3 规范 支持基本源映射
使用 Stylus 文件传递 --sourcemap 标志(或 -m)。这将创建一个 style.css 文件和一个 style.css.map 文件作为 style.styl 的同级文件,并在 style.css 底部放置一个指向源映射的源映射链接。
--sourcemap
-m
style.css
style.css.map
style.styl
stylus -m style.styl
你还可以一边监视文件一边运行此命令。例如:stylus -w -m style.styl。每次保存时,这都会更新你的源映射。
stylus -w -m style.styl
使用选项对象或布尔值设置 sourcemap 设置
sourcemap
var stylus = require('stylus'); var style = stylus(str) .set('filename', 'file.styl') .set('sourcemap', options); style.render(function(err, css) { // generated sourcemap object console.log(style.sourcemap); });
`comment` Adds a comment with the `sourceMappingURL` to the generated CSS (default: `true`) `inline` Inlines the sourcemap with full source text in base64 format (default: `false`) `sourceRoot` "sourceRoot" property of the generated sourcemap `basePath` Base path from which sourcemap and all sources are relative (default: `.`)