Skip to content

Commit

Permalink
fix(@angular/build): avoid rebasing URLs with function calls
Browse files Browse the repository at this point in the history
Function calls can alter the URL path, leading to issues during URL parsing.

Closes: #27688
  • Loading branch information
alan-agius4 authored and clydin committed May 23, 2024
1 parent c7205ea commit a82a741
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
5 changes: 5 additions & 0 deletions packages/angular/build/src/tools/sass/rebasing-importer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,11 @@ abstract class UrlRebasingImporter implements Importer<'sync'> {
continue;
}

// Skip if value is value contains a function call
if (/#\{.+\(.+\)\}/.test(value)) {
continue;
}

// Sass variable usage either starts with a `$` or contains a namespace and a `.$`
const valueNormalized = value[0] === '$' || /^\w+\.\$/.test(value) ? `#{${value}}` : value;
const rebasedPath =
Expand Down
22 changes: 22 additions & 0 deletions tests/legacy-cli/e2e/tests/build/styles/bootstrap.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { writeMultipleFiles } from '../../../utils/fs';
import { installPackage } from '../../../utils/packages';
import { ng } from '../../../utils/process';
import { updateJsonFile } from '../../../utils/project';

export default async function () {
// Install bootstrap
await installPackage('bootstrap@5');

await writeMultipleFiles({
'src/styles.scss': `
@import 'bootstrap/scss/bootstrap';
`,
});

await updateJsonFile('angular.json', (workspaceJson) => {
const appArchitect = workspaceJson.projects['test-project'].architect;
appArchitect.build.options.styles = [{ input: 'src/styles.scss' }];
});

await ng('build');
}

0 comments on commit a82a741

Please sign in to comment.