Skip to content

Commit e4883b0

Browse files
clydinangular-robot[bot]
authored andcommitted
feat(@angular-devkit/build-angular): support SSL options with esbuild development server
When using the esbuild-based browser application builder and its newly supported development server, the SSL related `dev-server` builder options can now be used. These include the existing `ssl`, `sslCert`, and `sslKey` options. Additionally, if no certificate and key are provided the `@vitejs/plugin-basic-ssl` plugin will be used to provide an auto-generated one.
1 parent f98c9de commit e4883b0

File tree

5 files changed

+26
-3
lines changed

5 files changed

+26
-3
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@
126126
"@typescript-eslint/eslint-plugin": "5.57.1",
127127
"@typescript-eslint/parser": "5.57.1",
128128
"@yarnpkg/lockfile": "1.1.0",
129+
"@vitejs/plugin-basic-ssl": "1.0.1",
129130
"ajv": "8.12.0",
130131
"ajv-formats": "2.1.1",
131132
"ansi-colors": "4.1.3",

packages/angular_devkit/build_angular/BUILD.bazel

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,14 +75,14 @@ ts_library(
7575
],
7676
) + [
7777
"//packages/angular_devkit/build_angular:src/builders/app-shell/schema.ts",
78-
"//packages/angular_devkit/build_angular:src/builders/browser/schema.ts",
7978
"//packages/angular_devkit/build_angular:src/builders/browser-esbuild/schema.ts",
79+
"//packages/angular_devkit/build_angular:src/builders/browser/schema.ts",
8080
"//packages/angular_devkit/build_angular:src/builders/dev-server/schema.ts",
8181
"//packages/angular_devkit/build_angular:src/builders/extract-i18n/schema.ts",
8282
"//packages/angular_devkit/build_angular:src/builders/karma/schema.ts",
83+
"//packages/angular_devkit/build_angular:src/builders/ng-packagr/schema.ts",
8384
"//packages/angular_devkit/build_angular:src/builders/protractor/schema.ts",
8485
"//packages/angular_devkit/build_angular:src/builders/server/schema.ts",
85-
"//packages/angular_devkit/build_angular:src/builders/ng-packagr/schema.ts",
8686
],
8787
data = glob(
8888
include = [
@@ -131,6 +131,7 @@ ts_library(
131131
"@npm//@types/node",
132132
"@npm//@types/semver",
133133
"@npm//@types/text-table",
134+
"@npm//@vitejs/plugin-basic-ssl",
134135
"@npm//ajv",
135136
"@npm//ansi-colors",
136137
"@npm//autoprefixer",

packages/angular_devkit/build_angular/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
"@babel/template": "7.20.7",
2323
"@discoveryjs/json-ext": "0.5.7",
2424
"@ngtools/webpack": "0.0.0-PLACEHOLDER",
25+
"@vitejs/plugin-basic-ssl": "1.0.1",
2526
"ansi-colors": "4.1.3",
2627
"autoprefixer": "10.4.14",
2728
"babel-loader": "9.1.2",

packages/angular_devkit/build_angular/src/builders/dev-server/vite-server.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import type { BuilderContext } from '@angular-devkit/architect';
1010
import type { json } from '@angular-devkit/core';
1111
import assert from 'node:assert';
1212
import { BinaryLike, createHash } from 'node:crypto';
13+
import { readFile } from 'node:fs/promises';
1314
import type { AddressInfo } from 'node:net';
1415
import path from 'node:path';
1516
import { InlineConfig, ViteDevServer, createServer, normalizePath } from 'vite';
@@ -186,7 +187,6 @@ async function setupServer(
186187
host: serverOptions.host,
187188
open: serverOptions.open,
188189
headers: serverOptions.headers,
189-
https: serverOptions.ssl,
190190
proxy,
191191
// Currently does not appear to be a way to disable file watching directly so ignore all files
192192
watch: {
@@ -271,6 +271,21 @@ async function setupServer(
271271
},
272272
};
273273

274+
if (serverOptions.ssl) {
275+
if (serverOptions.sslCert && serverOptions.sslKey) {
276+
// server configuration is defined above
277+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
278+
configuration.server!.https = {
279+
cert: await readFile(serverOptions.sslCert),
280+
key: await readFile(serverOptions.sslKey),
281+
};
282+
} else {
283+
const { default: basicSslPlugin } = await import('@vitejs/plugin-basic-ssl');
284+
configuration.plugins ??= [];
285+
configuration.plugins.push(basicSslPlugin());
286+
}
287+
}
288+
274289
const server = await createServer(configuration);
275290

276291
return server;

yarn.lock

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3927,6 +3927,11 @@
39273927
minimatch "3.1.2"
39283928
semver "7.3.8"
39293929

3930+
"@vitejs/plugin-basic-ssl@1.0.1":
3931+
version "1.0.1"
3932+
resolved "https://registry.yarnpkg.com/@vitejs/plugin-basic-ssl/-/plugin-basic-ssl-1.0.1.tgz#48c46eab21e0730921986ce742563ae83fe7fe34"
3933+
integrity sha512-pcub+YbFtFhaGRTo1832FQHQSHvMrlb43974e2eS8EKleR3p1cDdkJFPci1UhwkEf1J9Bz+wKBSzqpKp7nNj2A==
3934+
39303935
"@webassemblyjs/ast@1.11.1":
39313936
version "1.11.1"
39323937
resolved "https://registry.yarnpkg.com/@webassemblyjs/ast/-/ast-1.11.1.tgz#2bfd767eae1a6996f432ff7e8d7fc75679c0b6a7"

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy