diff --git a/packages/cli/src/lib/bundler/bundle.ts b/packages/cli/src/lib/bundler/bundle.ts index 79f58e8532..72931ec3e0 100644 --- a/packages/cli/src/lib/bundler/bundle.ts +++ b/packages/cli/src/lib/bundler/bundle.ts @@ -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 }); diff --git a/packages/cli/src/lib/bundler/config.ts b/packages/cli/src/lib/bundler/config.ts index a9d5c2aa67..7c72dc81f7 100644 --- a/packages/cli/src/lib/bundler/config.ts +++ b/packages/cli/src/lib/bundler/config.ts @@ -92,7 +92,7 @@ export async function createConfig( paths: BundlingPaths, options: BundlingOptions, ): Promise { - 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({ diff --git a/packages/cli/src/lib/bundler/server.ts b/packages/cli/src/lib/bundler/server.ts index f9d6f3590d..3954c1ee03 100644 --- a/packages/cli/src/lib/bundler/server.ts +++ b/packages/cli/src/lib/bundler/server.ts @@ -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( diff --git a/packages/cli/src/lib/bundler/types.ts b/packages/cli/src/lib/bundler/types.ts index 414414fa81..c836fd7a29 100644 --- a/packages/cli/src/lib/bundler/types.ts +++ b/packages/cli/src/lib/bundler/types.ts @@ -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 & {