Removing keycloak-resources dir from dist dir after build
This commit is contained in:
parent
73a8ec0295
commit
884b701fc6
@ -3,18 +3,21 @@ import { readParsedPackageJson } from "../bin/keycloakify/buildOptions/parsedPac
|
|||||||
import type { Plugin } from "vite";
|
import type { Plugin } from "vite";
|
||||||
import { assert } from "tsafe/assert";
|
import { assert } from "tsafe/assert";
|
||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
import { resolvedViteConfigJsonBasename, nameOfTheGlobal, basenameOfTheKeycloakifyResourcesDir } from "../bin/constants";
|
import { resolvedViteConfigJsonBasename, nameOfTheGlobal, basenameOfTheKeycloakifyResourcesDir, keycloak_resources } from "../bin/constants";
|
||||||
import type { ResolvedViteConfig } from "../bin/keycloakify/buildOptions/resolvedViteConfig";
|
import type { ResolvedViteConfig } from "../bin/keycloakify/buildOptions/resolvedViteConfig";
|
||||||
import { getKeycloakifyBuildDirPath } from "../bin/keycloakify/buildOptions/getKeycloakifyBuildDirPath";
|
import { getKeycloakifyBuildDirPath } from "../bin/keycloakify/buildOptions/getKeycloakifyBuildDirPath";
|
||||||
import { replaceAll } from "../bin/tools/String.prototype.replaceAll";
|
import { replaceAll } from "../bin/tools/String.prototype.replaceAll";
|
||||||
import { id } from "tsafe/id";
|
import { id } from "tsafe/id";
|
||||||
|
import { rm } from "../bin/tools/fs.rm";
|
||||||
|
|
||||||
export function keycloakify(): Plugin {
|
export function keycloakify(): Plugin {
|
||||||
let reactAppRootDirPath: string | undefined = undefined;
|
let reactAppRootDirPath: string | undefined = undefined;
|
||||||
let urlPathname: string | undefined = undefined;
|
let urlPathname: string | undefined = undefined;
|
||||||
|
let buildDirPath: string | undefined = undefined;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"name": "keycloakify",
|
"name": "keycloakify",
|
||||||
|
"apply": "build",
|
||||||
"configResolved": resolvedConfig => {
|
"configResolved": resolvedConfig => {
|
||||||
reactAppRootDirPath = resolvedConfig.root;
|
reactAppRootDirPath = resolvedConfig.root;
|
||||||
urlPathname = (() => {
|
urlPathname = (() => {
|
||||||
@ -35,6 +38,8 @@ export function keycloakify(): Plugin {
|
|||||||
return out;
|
return out;
|
||||||
})();
|
})();
|
||||||
|
|
||||||
|
buildDirPath = pathJoin(reactAppRootDirPath, resolvedConfig.build.outDir);
|
||||||
|
|
||||||
const { keycloakifyBuildDirPath } = getKeycloakifyBuildDirPath({
|
const { keycloakifyBuildDirPath } = getKeycloakifyBuildDirPath({
|
||||||
"parsedPackageJson_keycloakify_keycloakifyBuildDirPath": readParsedPackageJson({ reactAppRootDirPath }).keycloakify
|
"parsedPackageJson_keycloakify_keycloakifyBuildDirPath": readParsedPackageJson({ reactAppRootDirPath }).keycloakify
|
||||||
?.keycloakifyBuildDirPath,
|
?.keycloakifyBuildDirPath,
|
||||||
@ -113,6 +118,11 @@ export function keycloakify(): Plugin {
|
|||||||
return {
|
return {
|
||||||
"code": transformedCode
|
"code": transformedCode
|
||||||
};
|
};
|
||||||
|
},
|
||||||
|
"buildEnd": async () => {
|
||||||
|
assert(buildDirPath !== undefined);
|
||||||
|
|
||||||
|
await rm(pathJoin(buildDirPath, keycloak_resources), { "recursive": true, "force": true });
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user