Skip to content

Commit

Permalink
fix(@angular-devkit/build-angular): media files download files in vite
Browse files Browse the repository at this point in the history
Unlike assets, output file were not prefixed with a `/`. This change alings these and now files are always prefixed with a slash.

Closes #26215

(cherry picked from commit 8c76cb2)
  • Loading branch information
alan-agius4 committed Nov 3, 2023
1 parent 6d39427 commit c46f312
Showing 1 changed file with 8 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -315,8 +315,9 @@ function analyzeResultFiles(
// This mimics the Webpack dev-server behavior.
filePath = '/index.html';
} else {
filePath = normalizePath(file.path);
filePath = '/' + normalizePath(file.path);
}

seen.add(filePath);

// Skip analysis of sourcemaps
Expand Down Expand Up @@ -458,21 +459,19 @@ export async function setupServer(
// Remove query if present
const [importerFile] = importer.split('?', 1);

source = normalizePath(
join(dirname(relative(virtualProjectRoot, importerFile)), source),
);
}
if (source[0] === '/') {
source = source.slice(1);
source =
'/' +
normalizePath(join(dirname(relative(virtualProjectRoot, importerFile)), source));
}

const [file] = source.split('?', 1);
if (outputFiles.has(file)) {
return join(virtualProjectRoot, source);
}
},
load(id) {
const [file] = id.split('?', 1);
const relativeFile = normalizePath(relative(virtualProjectRoot, file));
const relativeFile = '/' + normalizePath(relative(virtualProjectRoot, file));
const codeContents = outputFiles.get(relativeFile)?.contents;
if (codeContents === undefined) {
if (relativeFile.endsWith('/node_modules/vite/dist/client/client.mjs')) {
Expand Down Expand Up @@ -590,7 +589,7 @@ export async function setupServer(
return;
}

const rawHtml = outputFiles.get('index.server.html')?.contents;
const rawHtml = outputFiles.get('/index.server.html')?.contents;
if (!rawHtml) {
next();

Expand Down

0 comments on commit c46f312

Please sign in to comment.