Skip to content

Commit ff7fa38

Browse files
committed
fix: enable css devSourcemap
1 parent dd7c990 commit ff7fa38

File tree

1 file changed

+9
-8
lines changed
  • packages/vite/src/node/plugins

1 file changed

+9
-8
lines changed

packages/vite/src/node/plugins/css.ts

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import type { TransformOptions } from 'esbuild'
2727
import { formatMessages, transform } from 'esbuild'
2828
import type { RawSourceMap } from '@ampproject/remapping'
2929
import { WorkerWithFallback } from 'artichokie'
30-
// import { getCodeWithSourcemap, injectSourcesContent } from '../server/sourcemap'
30+
import { getCodeWithSourcemap, injectSourcesContent } from '../server/sourcemap'
3131
import type { ModuleNode } from '../server/moduleGraph'
3232
import type { ResolveFn, ViteDevServer } from '../'
3333
import {
@@ -488,13 +488,14 @@ export function cssPostPlugin(config: ResolvedConfig): Plugin {
488488

489489
if (config.command === 'serve') {
490490
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+
}
498499
return content
499500
}
500501

0 commit comments

Comments
 (0)