Merge pull request #24300 from backstage/rugvip/app-mode

app-backend,cli: move backstage-app-mode injection to build time
This commit is contained in:
Patrik Oldsberg
2024-04-16 14:04:31 +02:00
committed by GitHub
4 changed files with 16 additions and 33 deletions
+11 -5
View File
@@ -41,6 +41,10 @@ export async function buildBundle(options: BuildOptions) {
const { statsJsonEnabled, schema: configSchema } = options;
const paths = resolveBundlingPaths(options);
const publicPaths = await resolveOptionalBundlingPaths({
entry: 'src/index-public-experimental',
dist: 'dist/public',
});
const detectedModulesEntryPoint = await createDetectedModulesEntryPoint({
config: options.fullConfig,
@@ -57,20 +61,22 @@ export async function buildBundle(options: BuildOptions) {
await createConfig(paths, {
...commonConfigOptions,
additionalEntryPoints: detectedModulesEntryPoint,
appMode: publicPaths ? 'protected' : 'public',
}),
];
const publicPaths = await resolveOptionalBundlingPaths({
entry: 'src/index-public-experimental',
dist: 'dist/public',
});
if (publicPaths) {
console.log(
chalk.yellow(
`⚠️ WARNING: The app /public entry point is an experimental feature that may receive immediate breaking changes.`,
),
);
configs.push(await createConfig(publicPaths, commonConfigOptions));
configs.push(
await createConfig(publicPaths, {
...commonConfigOptions,
appMode: 'public',
}),
);
}
const isCi = yn(process.env.CI, { default: false });
+3
View File
@@ -130,6 +130,9 @@ export async function createConfig(
plugins.push(
new HtmlWebpackPlugin({
meta: {
'backstage-app-mode': options?.appMode ?? 'public',
},
template: paths.targetHtml,
templateParameters: {
publicPath,
+2
View File
@@ -27,6 +27,8 @@ export type BundlingOptions = {
additionalEntryPoints?: string[];
// Path to append to the detected public path, e.g. '/public'
publicSubPath?: string;
// Mode that the app is running in, 'protected' or 'public', default is 'public'
appMode?: string;
};
export type ServeOptions = BundlingPathsOptions & {