Merge pull request #13338 from lsiric/feature/support-custom-certificate-for-webpack-dev-server

passing https.cert and https.key options to the webpack dev server
This commit is contained in:
Patrik Oldsberg
2022-09-01 18:25:44 +02:00
committed by GitHub
6 changed files with 46 additions and 2 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/cli': patch
---
Added support for custom certificate for webpack dev server.
-1
View File
@@ -7,7 +7,6 @@ app:
# applicationId: qwerty
# site: # datadoghq.eu default = datadoghq.com
# env: # optional
support:
url: https://github.com/backstage/backstage/issues # Used by common ErrorPage
items: # Used by common SupportButton component
+26
View File
@@ -248,6 +248,32 @@
"description": "The port that the frontend should be bound to. Only used for local development."
}
}
},
"https": {
"type": "object",
"description": "Only used for local development. The https object is passed to webpack in order to enable using https on localhost.",
"properties": {
"certificate": {
"type": "object",
"description": "Parent object containing certificate and the private key",
"required": [
"key",
"cert"
],
"properties": {
"key": {
"type": "string",
"visibility": "secret",
"description": "Https Certificate private key. Use $file to load in a file"
},
"cert": {
"type": "string",
"visibility": "secret",
"description": "Https Certificate. Use $file to load in a file"
}
}
}
}
}
}
}
+10 -1
View File
@@ -40,6 +40,7 @@ export async function serveBundle(options: ServeOptions) {
isDev: true,
baseUrl: url,
});
const compiler = webpack(config);
const server = new WebpackDevServer(
@@ -60,7 +61,15 @@ export async function serveBundle(options: ServeOptions) {
// See https://github.com/facebookincubator/create-react-app/issues/387.
disableDotRule: true,
},
https: url.protocol === 'https:',
https:
url.protocol === 'https:'
? {
cert: options.backendConfig.getString(
'app.https.certificate.cert',
),
key: options.backendConfig.getString('app.https.certificate.key'),
}
: false,
host,
port,
proxy: pkg.proxy,
+1
View File
@@ -31,6 +31,7 @@ export type ServeOptions = BundlingPathsOptions & {
checksEnabled: boolean;
frontendConfig: Config;
frontendAppConfigs: AppConfig[];
backendConfig: Config;
};
export type BuildOptions = BundlingPathsOptions & {
+4
View File
@@ -96,11 +96,15 @@ export async function loadCliConfig(options: Options) {
});
const frontendConfig = ConfigReader.fromConfigs(frontendAppConfigs);
const backendAppConfigs = schema.process(appConfigs);
const backendConfig = ConfigReader.fromConfigs(backendAppConfigs);
return {
schema,
appConfigs,
frontendConfig,
frontendAppConfigs,
backendConfig,
};
} catch (error) {
const maybeSchemaError = error as Error & { messages?: string[] };