Skip to content

Commit

Permalink
chore: shrink genSourceMapUrl type (#11667)
Browse files Browse the repository at this point in the history
  • Loading branch information
chenfan0 authored Jan 12, 2023
1 parent 111ecbf commit 9fb406b
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions packages/vite/src/node/server/sourcemap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export async function injectSourcesContent(
}
}

export function genSourceMapUrl(map: SourceMap | string | undefined): string {
export function genSourceMapUrl(map: SourceMap | string): string {
if (typeof map !== 'string') {
map = JSON.stringify(map)
}
Expand All @@ -69,16 +69,16 @@ export function genSourceMapUrl(map: SourceMap | string | undefined): string {
export function getCodeWithSourcemap(
type: 'js' | 'css',
code: string,
map: SourceMap | null,
map: SourceMap,
): string {
if (isDebug) {
code += `\n/*${JSON.stringify(map, null, 2).replace(/\*\//g, '*\\/')}*/\n`
}

if (type === 'js') {
code += `\n//# sourceMappingURL=${genSourceMapUrl(map ?? undefined)}`
code += `\n//# sourceMappingURL=${genSourceMapUrl(map)}`
} else if (type === 'css') {
code += `\n/*# sourceMappingURL=${genSourceMapUrl(map ?? undefined)} */`
code += `\n/*# sourceMappingURL=${genSourceMapUrl(map)} */`
}

return code
Expand Down

0 comments on commit 9fb406b

Please sign in to comment.