MCPcopy
hub / github.com/vitejs/vite / formatPostcssSourceMap

Function formatPostcssSourceMap

packages/vite/src/node/plugins/css.ts:1871–1897  ·  view source on GitHub ↗
(
  rawMap: ExistingRawSourceMap,
  file: string,
)

Source from the content-addressed store, hash-verified

1869}
1870
1871export async function formatPostcssSourceMap(
1872 rawMap: ExistingRawSourceMap,
1873 file: string,
1874): Promise<ExistingRawSourceMap> {
1875 const inputFileDir = path.dirname(file)
1876
1877 // Note: the real `Sourcemap#sources` maybe `null`, but rollup typing is not handle it.
1878 const sources = rawMap.sources!.map((source) => {
1879 const cleanSource = cleanUrl(decodeURIComponent(source!))
1880
1881 // postcss virtual files
1882 if (cleanSource[0] === '<' && cleanSource.endsWith('>')) {
1883 return `\0${cleanSource}`
1884 }
1885
1886 return normalizePath(path.resolve(inputFileDir, cleanSource))
1887 })
1888
1889 return {
1890 file,
1891 mappings: rawMap.mappings,
1892 names: rawMap.names,
1893 sources,
1894 sourcesContent: rawMap.sourcesContent,
1895 version: rawMap.version,
1896 }
1897}
1898
1899function combineSourcemapsIfExists(
1900 filename: string,

Callers 1

runPostCSSFunction · 0.85

Calls 3

cleanUrlFunction · 0.90
normalizePathFunction · 0.90
resolveMethod · 0.65

Tested by

no test coverage detected