cli: use correct public path for /auth entry point bundles

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
Patrik Oldsberg
2024-01-22 13:44:15 +01:00
parent 3a46297ddf
commit e7316e76fc
4 changed files with 21 additions and 4 deletions
+6 -1
View File
@@ -66,7 +66,12 @@ export async function buildBundle(options: BuildOptions) {
dist: 'dist/auth',
});
if (authPaths) {
configs.push(await createConfig(authPaths, commonConfigOptions));
configs.push(
await createConfig(authPaths, {
...commonConfigOptions,
publicSubPath: '/auth',
}),
);
}
const isCi = yn(process.env.CI, { default: false });
+6 -2
View File
@@ -92,7 +92,7 @@ export async function createConfig(
paths: BundlingPaths,
options: BundlingOptions,
): Promise<webpack.Configuration> {
const { checksEnabled, isDev, frontendConfig } = options;
const { checksEnabled, isDev, frontendConfig, publicSubPath = '' } = options;
const { plugins, loaders } = transforms(options);
// Any package that is part of the monorepo but outside the monorepo root dir need
@@ -102,7 +102,11 @@ export async function createConfig(
const baseUrl = frontendConfig.getString('app.baseUrl');
const validBaseUrl = new URL(baseUrl);
const publicPath = validBaseUrl.pathname.replace(/\/$/, '');
let publicPath = validBaseUrl.pathname.replace(/\/$/, '');
if (publicSubPath) {
publicPath = `${publicPath}${publicSubPath}`.replace('//', '/');
}
if (checksEnabled) {
plugins.push(
new ForkTsCheckerWebpackPlugin({
+7 -1
View File
@@ -208,7 +208,13 @@ DEPRECATION WARNING: React Router Beta is deprecated and support for it will be
dist: 'dist/auth',
});
const compiler = authPaths
? webpack([config, await createConfig(authPaths, commonConfigOptions)])
? webpack([
config,
await createConfig(authPaths, {
...commonConfigOptions,
publicSubPath: '/auth',
}),
])
: webpack(config);
webpackServer = new WebpackDevServer(
+2
View File
@@ -26,6 +26,8 @@ export type BundlingOptions = {
baseUrl: URL;
parallelism?: number;
additionalEntryPoints?: string[];
// Path to append to the detected public path, e.g. '/auth'
publicSubPath?: string;
};
export type ServeOptions = BundlingPathsOptions & {