Skip to content

Commit 3303073

Browse files
alan-agius4filipesilva
authored andcommitted
fix(@angular-devkit/build-angular): inlining fonts behind proxy
With this change users can now their proxy server via the `HTTPS_PROXY` environment variable. The specified proxy will be used when making requests to inline fonts. Closes #19401 (cherry picked from commit 9af0942)
1 parent fd937b3 commit 3303073

File tree

7 files changed

+25
-12
lines changed

7 files changed

+25
-12
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@
156156
"git-raw-commits": "^2.0.0",
157157
"glob": "7.1.6",
158158
"http-proxy": "^1.18.1",
159+
"https-proxy-agent": "5.0.0",
159160
"husky": "5.0.6",
160161
"inquirer": "7.3.3",
161162
"jasmine": "^3.3.1",

packages/angular/cli/lib/config/schema.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -751,15 +751,15 @@
751751
]
752752
},
753753
"fonts": {
754-
"description": "Enables optimization for fonts. This requires internet access.",
754+
"description": "Enables optimization for fonts. This option requires internet access. `HTTPS_PROXY` environment variable can be used to specify a proxy server.",
755755
"default": true,
756756
"oneOf": [
757757
{
758758
"type": "object",
759759
"properties": {
760760
"inline": {
761761
"type": "boolean",
762-
"description": "Reduce render blocking requests by inlining external Google fonts and icons CSS definitions in the application's HTML index file. This requires internet access.",
762+
"description": "Reduce render blocking requests by inlining external Google fonts and icons CSS definitions in the application's HTML index file. This option requires internet access. `HTTPS_PROXY` environment variable can be used to specify a proxy server.",
763763
"default": true
764764
}
765765
},

packages/angular_devkit/build_angular/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ ts_library(
153153
"@npm//file-loader",
154154
"@npm//find-cache-dir",
155155
"@npm//glob",
156+
"@npm//https-proxy-agent",
156157
"@npm//inquirer",
157158
"@npm//jest-worker",
158159
"@npm//karma",

packages/angular_devkit/build_angular/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
"file-loader": "6.2.0",
3535
"find-cache-dir": "3.3.1",
3636
"glob": "7.1.6",
37+
"https-proxy-agent": "5.0.0",
3738
"inquirer": "7.3.3",
3839
"jest-worker": "26.6.2",
3940
"karma-source-map-support": "1.4.0",

packages/angular_devkit/build_angular/src/browser/schema.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,15 +95,15 @@
9595
]
9696
},
9797
"fonts": {
98-
"description": "Enables optimization for fonts. This requires internet access.",
98+
"description": "Enables optimization for fonts. This option requires internet access. `HTTPS_PROXY` environment variable can be used to specify a proxy server.",
9999
"default": true,
100100
"oneOf": [
101101
{
102102
"type": "object",
103103
"properties": {
104104
"inline": {
105105
"type": "boolean",
106-
"description": "Reduce render blocking requests by inlining external Google fonts and icons CSS definitions in the application's HTML index file. This requires internet access.",
106+
"description": "Reduce render blocking requests by inlining external Google fonts and icons CSS definitions in the application's HTML index file. This option requires internet access. `HTTPS_PROXY` environment variable can be used to specify a proxy server.",
107107
"default": true
108108
}
109109
},

packages/angular_devkit/build_angular/src/utils/index-file/inline-fonts.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
import * as cacache from 'cacache';
1010
import * as https from 'https';
11+
import * as proxyAgent from 'https-proxy-agent';
1112
import { URL } from 'url';
1213
import { findCachePath } from '../cache-path';
1314
import { cachingDisabled } from '../environment-options';
@@ -100,11 +101,20 @@ export class InlineFontsProcessor {
100101
}
101102
}
102103

104+
let agent: proxyAgent.HttpsProxyAgent | undefined;
105+
const httpsProxy = process.env.HTTPS_PROXY ?? process.env.https_proxy;
106+
107+
if (httpsProxy) {
108+
agent = proxyAgent(httpsProxy);
109+
}
110+
103111
const data = await new Promise<string>((resolve, reject) => {
104112
let rawResponse = '';
105113
https.get(
106114
url,
107115
{
116+
agent,
117+
rejectUnauthorized: false,
108118
headers: {
109119
'user-agent': userAgent,
110120
},

yarn.lock

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6078,6 +6078,14 @@ https-browserify@^1.0.0:
60786078
resolved "https://registry.yarnpkg.com/https-browserify/-/https-browserify-1.0.0.tgz#ec06c10e0a34c0f2faf199f7fd7fc78fffd03c73"
60796079
integrity sha1-7AbBDgo0wPL68Zn3/X/Hj//QPHM=
60806080

6081+
[email protected], https-proxy-agent@^5.0.0:
6082+
version "5.0.0"
6083+
resolved "https://registry.yarnpkg.com/https-proxy-agent/-/https-proxy-agent-5.0.0.tgz#e2a90542abb68a762e0a0850f6c9edadfd8506b2"
6084+
integrity sha512-EkYm5BcKUGiduxzSt3Eppko+PiNWNEpa4ySk9vTC6wDsQJW9rHSa+UhGNJoRYp7bz6Ht1eaRIa6QaJqO5rCFbA==
6085+
dependencies:
6086+
agent-base "6"
6087+
debug "4"
6088+
60816089
https-proxy-agent@^2.2.1:
60826090
version "2.2.4"
60836091
resolved "https://registry.yarnpkg.com/https-proxy-agent/-/https-proxy-agent-2.2.4.tgz#4ee7a737abd92678a293d9b34a1af4d0d08c787b"
@@ -6094,14 +6102,6 @@ https-proxy-agent@^4.0.0:
60946102
agent-base "5"
60956103
debug "4"
60966104

6097-
https-proxy-agent@^5.0.0:
6098-
version "5.0.0"
6099-
resolved "https://registry.yarnpkg.com/https-proxy-agent/-/https-proxy-agent-5.0.0.tgz#e2a90542abb68a762e0a0850f6c9edadfd8506b2"
6100-
integrity sha512-EkYm5BcKUGiduxzSt3Eppko+PiNWNEpa4ySk9vTC6wDsQJW9rHSa+UhGNJoRYp7bz6Ht1eaRIa6QaJqO5rCFbA==
6101-
dependencies:
6102-
agent-base "6"
6103-
debug "4"
6104-
61056105
humanize-ms@^1.2.1:
61066106
version "1.2.1"
61076107
resolved "https://registry.yarnpkg.com/humanize-ms/-/humanize-ms-1.2.1.tgz#c46e3159a293f6b896da29316d8b6fe8bb79bbed"

0 commit comments

Comments
 (0)