@@ -3,7 +3,7 @@ import * as async from "async";
3
3
import * as convertSourceMap from "convert-source-map" ;
4
4
import * as debugGenerator from "debug" ;
5
5
import * as fs from "fs" ;
6
- import { postcss } from "opticss" ;
6
+ import { adaptFromLegacySourceMap , adaptToLegacySourceMap , postcss } from "opticss" ;
7
7
import * as path from "path" ;
8
8
import { RawSourceMap } from "source-map" ;
9
9
import { Compiler as WebpackCompiler } from "webpack" ;
@@ -259,7 +259,7 @@ function assetAsSource(contents: string, filename: string): Source {
259
259
let sm : RawSourceMap = sourcemap . toObject ( ) ;
260
260
contents = convertSourceMap . removeComments ( contents ) ;
261
261
contents = convertSourceMap . removeMapFileComments ( contents ) ;
262
- return new SourceMapSource ( contents , filename , sm ) ;
262
+ return new SourceMapSource ( contents , filename , adaptToLegacySourceMap ( sm ) ) ;
263
263
} else {
264
264
return new RawSource ( contents ) ;
265
265
}
@@ -315,7 +315,8 @@ function assetFileAsSource(sourcePath: string, callback: (err: Error | undefined
315
315
function sourceAndMap ( asset : Source ) : SourceAndMap {
316
316
// sourceAndMap is supposedly more efficient when implemented.
317
317
if ( asset . sourceAndMap ) {
318
- return asset . sourceAndMap ( ) ;
318
+ let { source, map} = asset . sourceAndMap ( ) ;
319
+ return { source, map : adaptFromLegacySourceMap ( map ) } ;
319
320
} else {
320
321
let source = asset . source ( ) ;
321
322
let map : RawSourceMap | undefined = undefined ;
@@ -349,7 +350,7 @@ function makePostcssProcessor (
349
350
} ) ;
350
351
351
352
return result . then ( ( result ) => {
352
- return new SourceMapSource ( result . css , assetPath , result . map . toJSON ( ) , source , map ) ;
353
+ return new SourceMapSource ( result . css , assetPath , result . map . toJSON ( ) , source , map && adaptToLegacySourceMap ( map ) ) ;
353
354
} ) ;
354
355
} ) ;
355
356
} ;
0 commit comments