From 2a6e9af9c9d50ee7e231e70e4603a0f886bf988e Mon Sep 17 00:00:00 2001 From: Joseph Garrone Date: Sun, 16 Jun 2024 14:05:23 +0200 Subject: [PATCH] Enable to use an other directory than build/assets in webpack --- src/bin/shared/buildContext.ts | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/bin/shared/buildContext.ts b/src/bin/shared/buildContext.ts index ecda7e46..9dd340e5 100644 --- a/src/bin/shared/buildContext.ts +++ b/src/bin/shared/buildContext.ts @@ -137,6 +137,7 @@ export function getBuildContext(params: { const parsedPackageJson = (() => { type BuildOptions_packageJson = BuildOptions & { projectBuildDirPath?: string; + staticDirPathInBuildDirPath?: string; }; type ParsedPackageJson = { @@ -169,6 +170,7 @@ export function getBuildContext(params: { ) .optional(), themeName: z.union([z.string(), z.array(z.string())]).optional(), + staticDirPathInBuildDirPath: z.string().optional(), keycloakVersionTargets: id< z.ZodType >( @@ -229,7 +231,7 @@ export function getBuildContext(params: { ); })(); - const buildOptions: BuildOptions = { + const buildOptions = { ...parsedPackageJson.keycloakify, ...resolvedViteConfig?.buildOptions }; @@ -309,9 +311,9 @@ export function getBuildContext(params: { break webpack; } - if (parsedPackageJson.keycloakify?.projectBuildDirPath !== undefined) { + if (buildOptions.projectBuildDirPath !== undefined) { return getAbsoluteAndInOsFormatPath({ - pathIsh: parsedPackageJson.keycloakify.projectBuildDirPath, + pathIsh: buildOptions.projectBuildDirPath, cwd: projectDirPath }); } @@ -438,6 +440,13 @@ export function getBuildContext(params: { break webpack; } + if (buildOptions.staticDirPathInBuildDirPath !== undefined) { + getAbsoluteAndInOsFormatPath({ + pathIsh: buildOptions.staticDirPathInBuildDirPath, + cwd: projectBuildDirPath + }); + } + return pathJoin(projectBuildDirPath, "static"); }