@@ -27,7 +27,7 @@ import type { TransformOptions } from 'esbuild'
27
27
import { formatMessages , transform } from 'esbuild'
28
28
import type { RawSourceMap } from '@ampproject/remapping'
29
29
import { WorkerWithFallback } from 'artichokie'
30
- // import { getCodeWithSourcemap, injectSourcesContent } from '../server/sourcemap'
30
+ import { getCodeWithSourcemap , injectSourcesContent } from '../server/sourcemap'
31
31
import type { ModuleNode } from '../server/moduleGraph'
32
32
import type { ResolveFn , ViteDevServer } from '../'
33
33
import {
@@ -488,13 +488,14 @@ export function cssPostPlugin(config: ResolvedConfig): Plugin {
488
488
489
489
if ( config . command === 'serve' ) {
490
490
const getContentWithSourcemap = async ( content : string ) => {
491
- // if (config.css?.devSourcemap) {
492
- // const sourcemap = this.getCombinedSourcemap()
493
- // if (sourcemap.mappings) {
494
- // await injectSourcesContent(sourcemap, cleanUrl(id), config.logger)
495
- // }
496
- // return getCodeWithSourcemap('css', content, sourcemap)
497
- // }
491
+ if ( config . css ?. devSourcemap ) {
492
+ // @ts -expect-error missing types
493
+ const sourcemap = this . getCombinedSourcemap ( )
494
+ if ( sourcemap . mappings ) {
495
+ await injectSourcesContent ( sourcemap , cleanUrl ( id ) , config . logger )
496
+ }
497
+ return getCodeWithSourcemap ( 'css' , content , sourcemap )
498
+ }
498
499
return content
499
500
}
500
501
0 commit comments