Skip to content

Commit 8d09594

Browse files
Alan Agiusvikerman
Alan Agius
authored andcommitted
fix(@angular-devkit/build-angular): resolve fonts with space in filename
At the moment the uri of the font instead of spaced it will be `%20`, hence we need to decode it first before trying to resolve it. Fixes #9648
1 parent eb5643e commit 8d09594

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

packages/angular_devkit/build_angular/src/angular-cli-files/plugins/postcss-cli-resources.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ export default postcss.plugin('postcss-cli-resources', (options: PostcssCliResou
103103

104104
const { pathname, hash, search } = url.parse(inputUrl.replace(/\\/g, '/'));
105105
const resolver = (file: string, base: string) => new Promise<string>((resolve, reject) => {
106-
loader.resolve(base, file, (err, result) => {
106+
loader.resolve(base, decodeURI(file), (err, result) => {
107107
if (err) {
108108
reject(err);
109109

packages/angular_devkit/build_angular/test/browser/styles2_spec_large.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -575,4 +575,24 @@ describe('Browser Builder styles', () => {
575575
const { files } = await browserBuild(architect, host, target, overrides);
576576
expect(await files['styles.css']).toContain('background-image:url(//cdn.com/classic-bg.jpg)');
577577
});
578+
579+
it('supports fonts with space in filename', async () => {
580+
host.writeMultipleFiles({
581+
'src/styles.css': `
582+
@font-face {
583+
font-family: "Font Awesome";
584+
src: url("./assets/fa solid-900.woff2") format("woff2");
585+
}
586+
587+
body {
588+
font-family: "Font Awesome";
589+
}
590+
`,
591+
'src/assets/fa solid-900.woff2': '',
592+
});
593+
594+
const overrides = { extractCss: true };
595+
const { output } = await browserBuild(architect, host, target, overrides);
596+
expect(output.success).toBe(true);
597+
});
578598
});

0 commit comments

Comments
 (0)