From da0e3ba1c728f2fd40ef05e9f95cb6e7eecfa010 Mon Sep 17 00:00:00 2001 From: Jack Hsu Date: Fri, 20 Jan 2023 14:36:59 -0500 Subject: [PATCH] fix(webpack): handle new https options in webpack-dev-server (#14520) --- e2e/web/src/web-webpack.test.ts | 23 +++++++++++++++++++ .../dev-server/lib/get-dev-server-config.ts | 4 +++- 2 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 e2e/web/src/web-webpack.test.ts diff --git a/e2e/web/src/web-webpack.test.ts b/e2e/web/src/web-webpack.test.ts new file mode 100644 index 0000000000000..6175ae5143724 --- /dev/null +++ b/e2e/web/src/web-webpack.test.ts @@ -0,0 +1,23 @@ +import { + cleanupProject, + newProject, + runCLI, + runCommandUntil, + uniq, +} from '@nrwl/e2e/utils'; + +describe('Web Components Applications with bundler set as webpack', () => { + beforeEach(() => newProject()); + afterEach(() => cleanupProject()); + + it('should support https for dev-server', async () => { + const appName = uniq('app'); + runCLI( + `generate @nrwl/web:app ${appName} --bundler=webpack --no-interactive` + ); + + await runCommandUntil(`serve ${appName} --port=5000 --ssl`, (output) => { + return output.includes('listening at https://localhost:5000'); + }); + }, 300_000); +}); diff --git a/packages/webpack/src/executors/dev-server/lib/get-dev-server-config.ts b/packages/webpack/src/executors/dev-server/lib/get-dev-server-config.ts index 403a1fc71b62b..59e7f1cacbbf6 100644 --- a/packages/webpack/src/executors/dev-server/lib/get-dev-server-config.ts +++ b/packages/webpack/src/executors/dev-server/lib/get-dev-server-config.ts @@ -80,9 +80,11 @@ function getDevServerPartial( htmlAcceptHeaders: ['text/html', 'application/xhtml+xml'], }, onListening(server: any) { + const isHttps = + server.options.https || server.options.server?.type === 'https'; logger.info( `NX Web Development Server is listening at ${ - server.options.https ? 'https' : 'http' + isHttps ? 'https' : 'http' }://${server.options.host}:${server.options.port}${buildServePath( buildOptions )}`