mirror of
https://github.com/hanzoai/postcss.git
synced 2026-09-24 17:01:56 +00:00
absolute sourcemaps have source content
This commit is contained in:
+11
-4
@@ -97,10 +97,17 @@ class MapGenerator {
|
||||
let from = node.source.input.from
|
||||
if (from && !already[from]) {
|
||||
already[from] = true
|
||||
this.map.setSourceContent(
|
||||
this.toUrl(this.path(from)),
|
||||
node.source.input.css
|
||||
)
|
||||
let fromUrl = this.toUrl(this.path(from))
|
||||
if (this.mapOpts.absolute) {
|
||||
if (pathToFileURL) {
|
||||
fromUrl = pathToFileURL(from).toString()
|
||||
} else {
|
||||
throw new Error(
|
||||
'`map.absolute` option is not available in this PostCSS build'
|
||||
)
|
||||
}
|
||||
}
|
||||
this.map.setSourceContent(fromUrl, node.source.input.css)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
Generated
+6584
File diff suppressed because it is too large
Load Diff
@@ -722,4 +722,15 @@ test('supports previous inline map with empty processor', () => {
|
||||
match((root3.source?.input.origin(1, 0) as any).file, 'a.css')
|
||||
})
|
||||
|
||||
test('absolute sourcemaps have source contents', () => {
|
||||
let result = postcss([() => {}]).process('a{}', {
|
||||
from: '/dir/to/a.css',
|
||||
map: {
|
||||
inline: false,
|
||||
absolute: true
|
||||
}
|
||||
})
|
||||
equal(result.map.toJSON().sourcesContent, ['a{}'])
|
||||
})
|
||||
|
||||
test.run()
|
||||
|
||||
Reference in New Issue
Block a user