File tree 1 file changed +12
-2
lines changed
1 file changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -4,8 +4,13 @@ import stylus from 'stylus';
4
4
5
5
import { getIncludePaths } from '../modules/utils' ;
6
6
7
+ import type { SourceMap } from 'magic-string' ;
7
8
import type { Transformer , Options } from '../types' ;
8
9
10
+ type StylusRendererWithSourceMap = ReturnType < typeof stylus > & {
11
+ sourcemap : SourceMap ;
12
+ } ;
13
+
9
14
const transformer : Transformer < Options . Stylus > = ( {
10
15
content,
11
16
filename,
@@ -20,15 +25,20 @@ const transformer: Transformer<Options.Stylus> = ({
20
25
const style = stylus ( content , {
21
26
filename,
22
27
...options ,
23
- } ) . set ( 'sourcemap' , options . sourcemap ) ;
28
+ } ) . set ( 'sourcemap' , options . sourcemap ) as StylusRendererWithSourceMap ;
24
29
25
30
style . render ( ( err , css ) => {
26
31
// istanbul ignore next
27
32
if ( err ) reject ( err ) ;
33
+ if ( style . sourcemap ?. sources ) {
34
+ style . sourcemap . sources = style . sourcemap . sources . map ( ( source ) =>
35
+ path . resolve ( source ) ,
36
+ ) ;
37
+ }
28
38
29
39
resolve ( {
30
40
code : css ,
31
- map : ( style as any ) . sourcemap ,
41
+ map : style . sourcemap ,
32
42
// .map() necessary for windows compatibility
33
43
dependencies : style
34
44
. deps ( filename as string )
You can’t perform that action at this time.
0 commit comments