From 8d0959487403e587074aa2f4644c6bfe90e54b98 Mon Sep 17 00:00:00 2001 From: Alan Agius Date: Wed, 13 Mar 2019 16:16:36 +0100 Subject: [PATCH] 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 --- .../plugins/postcss-cli-resources.ts | 2 +- .../test/browser/styles2_spec_large.ts | 20 +++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/packages/angular_devkit/build_angular/src/angular-cli-files/plugins/postcss-cli-resources.ts b/packages/angular_devkit/build_angular/src/angular-cli-files/plugins/postcss-cli-resources.ts index 7588d50ec7c1..2f709376f2dd 100644 --- a/packages/angular_devkit/build_angular/src/angular-cli-files/plugins/postcss-cli-resources.ts +++ b/packages/angular_devkit/build_angular/src/angular-cli-files/plugins/postcss-cli-resources.ts @@ -103,7 +103,7 @@ export default postcss.plugin('postcss-cli-resources', (options: PostcssCliResou const { pathname, hash, search } = url.parse(inputUrl.replace(/\\/g, '/')); const resolver = (file: string, base: string) => new Promise((resolve, reject) => { - loader.resolve(base, file, (err, result) => { + loader.resolve(base, decodeURI(file), (err, result) => { if (err) { reject(err); diff --git a/packages/angular_devkit/build_angular/test/browser/styles2_spec_large.ts b/packages/angular_devkit/build_angular/test/browser/styles2_spec_large.ts index 935c66a20b93..220f9a98548d 100644 --- a/packages/angular_devkit/build_angular/test/browser/styles2_spec_large.ts +++ b/packages/angular_devkit/build_angular/test/browser/styles2_spec_large.ts @@ -575,4 +575,24 @@ describe('Browser Builder styles', () => { const { files } = await browserBuild(architect, host, target, overrides); expect(await files['styles.css']).toContain('background-image:url(//cdn.com/classic-bg.jpg)'); }); + + it('supports fonts with space in filename', async () => { + host.writeMultipleFiles({ + 'src/styles.css': ` + @font-face { + font-family: "Font Awesome"; + src: url("./assets/fa solid-900.woff2") format("woff2"); + } + + body { + font-family: "Font Awesome"; + } + `, + 'src/assets/fa solid-900.woff2': '', + }); + + const overrides = { extractCss: true }; + const { output } = await browserBuild(architect, host, target, overrides); + expect(output.success).toBe(true); + }); });