Appearance
源映射
¥Sourcemaps
Stylus 支持符合 Sourcemap v3 规范 的基本源映射
¥Stylus supports basic sourcemaps according to the Sourcemap v3 spec
创建源映射
¥Create a sourcemap
使用 Stylus 文件传递 --sourcemap
标志(或 -m
)。这将创建一个 style.css
文件和一个 style.css.map
文件作为 style.styl
的同级文件,并在 style.css
的底部放置一个指向源映射的源映射链接。
¥Pass the --sourcemap
flag (or -m
) with a Stylus file. This will create a style.css
file, and a style.css.map
file as siblings to your style.styl
and place a sourcemap link at the bottom of style.css
to your sourcemap.
stylus -m style.styl
stylus -m style.styl
你还可以在监视文件时运行此命令。例如:stylus -w -m style.styl
。这将在你每次保存时更新你的源映射。
¥You can also run this command while watching a file. For instance: stylus -w -m style.styl
. This will update your sourcemap everytime you save.
JavaScript API
使用选项对象或布尔值设置 sourcemap
设置:
¥Set the sourcemap
setting with an options object or a boolean value:
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);
});
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);
});
选项
¥Options
`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: `.`)
`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: `.`)