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 @@ -126,16 +126,21 @@ export class ComponentStylesheetBundler {
for (const outputFile of result.outputFiles) {
const filename = path.basename(outputFile.path);

// Needed for Bazel as otherwise the files will not be written in the correct place.
outputFile.path = path.join(this.options.workspaceRoot, outputFile.path);
if (outputFile.type === BuildOutputFileType.Media || filename.endsWith('.css.map')) {
// The output files could also contain resources (images/fonts/etc.) that were referenced and the map files.

if (outputFile.type === BuildOutputFileType.Media) {
// The output files could also contain resources (images/fonts/etc.) that were referenced
outputFiles.push(outputFile);
// Clone the output file to avoid amending the original path which would causes problems during rebuild.
const clonedOutputFile = outputFile.clone();

// Needed for Bazel as otherwise the files will not be written in the correct place,
// this is because esbuild will resolve the output file from the outdir which is currently set to `workspaceRoot` twice,
// once in the stylesheet and the other in the application code bundler.
// Ex: `../../../../../app.component.css.map`.
clonedOutputFile.path = path.join(this.options.workspaceRoot, outputFile.path);

outputFiles.push(clonedOutputFile);
} else if (filename.endsWith('.css')) {
contents = outputFile.text;
} else if (filename.endsWith('.css.map')) {
outputFiles.push(outputFile);
} else {
throw new Error(
`Unexpected non CSS/Media file "${filename}" outputted during component stylesheet processing.`,
Expand Down