Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -228,13 +228,12 @@ export async function setupServer(
return;
}

const code = Buffer.from(codeContents).toString('utf-8');
const mapContents = outputFiles.get(file + '.map')?.contents;

return {
// Remove source map URL comments from the code if a sourcemap is present.
// Vite will inline and add an additional sourcemap URL for the sourcemap.
code: mapContents ? code.replace(/^\/\/# sourceMappingURL=[^\r\n]*/gm, '') : code,
code: Buffer.from(codeContents).toString('utf-8'),
map: mapContents && Buffer.from(mapContents).toString('utf-8'),
};
},
Expand Down Expand Up @@ -262,7 +261,7 @@ export async function setupServer(
// Resource files are handled directly.
// Global stylesheets (CSS files) are currently considered resources to workaround
// dev server sourcemap issues with stylesheets.
if (extension !== '.js' && extension !== '.html') {
if (extension !== '.html') {
const outputFile = outputFiles.get(parsedUrl.pathname);
if (outputFile) {
const mimeType = lookupMimeType(extension);
Expand Down