Skip to content

Commit 7d253e9

Browse files
alan-agius4clydin
authored andcommittedMay 23, 2024·
fix(@angular/build): avoid rebasing URLs with function calls
Function calls can alter the URL path, leading to issues during URL parsing. Closes: #27688 (cherry picked from commit a82a741)
1 parent 706423a commit 7d253e9

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed
 

Diff for: ‎packages/angular/build/src/tools/sass/rebasing-importer.ts

+5
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,11 @@ abstract class UrlRebasingImporter implements Importer<'sync'> {
9393
continue;
9494
}
9595

96+
// Skip if value is value contains a function call
97+
if (/#\{.+\(.+\)\}/.test(value)) {
98+
continue;
99+
}
100+
96101
// Sass variable usage either starts with a `$` or contains a namespace and a `.$`
97102
const valueNormalized = value[0] === '$' || /^\w+\.\$/.test(value) ? `#{${value}}` : value;
98103
const rebasedPath =

Diff for: ‎tests/legacy-cli/e2e/tests/build/styles/bootstrap.ts

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { writeMultipleFiles } from '../../../utils/fs';
2+
import { installPackage } from '../../../utils/packages';
3+
import { ng } from '../../../utils/process';
4+
import { updateJsonFile } from '../../../utils/project';
5+
6+
export default async function () {
7+
// Install bootstrap
8+
await installPackage('bootstrap@5');
9+
10+
await writeMultipleFiles({
11+
'src/styles.scss': `
12+
@import 'bootstrap/scss/bootstrap';
13+
`,
14+
});
15+
16+
await updateJsonFile('angular.json', (workspaceJson) => {
17+
const appArchitect = workspaceJson.projects['test-project'].architect;
18+
appArchitect.build.options.styles = [{ input: 'src/styles.scss' }];
19+
});
20+
21+
await ng('build');
22+
}

0 commit comments

Comments
 (0)
Please sign in to comment.