ソースマップ
Stylusは、Sourcemap v3仕様に従って基本的なソースマップをサポートしています。
ソースマップの作成
Stylusファイルで`--sourcemap`フラグ(または`-m`)を渡します。これにより、`style.css`ファイルと`style.css.map`ファイルが`style.styl`と兄弟として作成され、ソースマップへのリンクが`style.css`の下部に配置されます。
stylus -m style.styl
stylus -m style.styl
ファイルの監視中にこのコマンドを実行することもできます。例えば:`stylus -w -m style.styl`。これにより、保存するたびにソースマップが更新されます。
JavaScript API
オプションオブジェクトまたはブール値で`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);
});
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: `.`)
`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: `.`)