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

Function formatPostcssSourceMap

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

Source from the content-addressed store, hash-verified

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

Callers 1

runPostCSSFunction · 0.85

Calls 3

cleanUrlFunction · 0.90
normalizePathFunction · 0.90
resolveMethod · 0.65

Tested by

no test coverage detected