Tweak the resources of the default theme that are kept
This commit is contained in:
@ -62,9 +62,9 @@ export async function downloadBuiltinKeycloakTheme(params: { keycloakVersion: st
|
|||||||
|
|
||||||
// Note, this is an optimization for reducing the size of the jar
|
// Note, this is an optimization for reducing the size of the jar
|
||||||
remove_unused_node_modules: {
|
remove_unused_node_modules: {
|
||||||
const pathOfNodeModules = pathJoin(destDirPath, "keycloak", "common", "resources", "node_modules");
|
const nodeModuleDirPath = pathJoin(destDirPath, "keycloak", "common", "resources", "node_modules");
|
||||||
|
|
||||||
if (!fs.existsSync(pathOfNodeModules)) {
|
if (!fs.existsSync(nodeModuleDirPath)) {
|
||||||
break remove_unused_node_modules;
|
break remove_unused_node_modules;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -114,8 +114,8 @@ export async function downloadBuiltinKeycloakTheme(params: { keycloakVersion: st
|
|||||||
];
|
];
|
||||||
|
|
||||||
transformCodebase({
|
transformCodebase({
|
||||||
"srcDirPath": pathOfNodeModules,
|
"srcDirPath": nodeModuleDirPath,
|
||||||
"destDirPath": pathOfNodeModules,
|
"destDirPath": nodeModuleDirPath,
|
||||||
"transformSourceCode": ({ sourceCode, fileRelativePath }) => {
|
"transformSourceCode": ({ sourceCode, fileRelativePath }) => {
|
||||||
if (fileRelativePath.endsWith(".map")) {
|
if (fileRelativePath.endsWith(".map")) {
|
||||||
return undefined;
|
return undefined;
|
||||||
@ -140,6 +140,33 @@ export async function downloadBuiltinKeycloakTheme(params: { keycloakVersion: st
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Just like node_modules
|
||||||
|
remove_unused_lib: {
|
||||||
|
const libDirPath = pathJoin(destDirPath, "keycloak", "common", "resources", "lib");
|
||||||
|
|
||||||
|
if (!fs.existsSync(libDirPath)) {
|
||||||
|
break remove_unused_lib;
|
||||||
|
}
|
||||||
|
|
||||||
|
const toDeletePerfixes = ["ui-ace", "filesaver", "fileupload", "angular", "ui-ace", "pficon"];
|
||||||
|
|
||||||
|
transformCodebase({
|
||||||
|
"srcDirPath": libDirPath,
|
||||||
|
"destDirPath": libDirPath,
|
||||||
|
"transformSourceCode": ({ sourceCode, fileRelativePath }) => {
|
||||||
|
if (fileRelativePath.endsWith(".map")) {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (toDeletePerfixes.find(prefix => fileRelativePath.startsWith(prefix)) !== undefined) {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
return { "modifiedSourceCode": sourceCode };
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
last_account_v1_transformations: {
|
last_account_v1_transformations: {
|
||||||
if (lastKeycloakVersionWithAccountV1 !== keycloakVersion) {
|
if (lastKeycloakVersionWithAccountV1 !== keycloakVersion) {
|
||||||
break last_account_v1_transformations;
|
break last_account_v1_transformations;
|
||||||
@ -187,34 +214,20 @@ export async function downloadBuiltinKeycloakTheme(params: { keycloakVersion: st
|
|||||||
{
|
{
|
||||||
const nodeModulesDirPath = pathJoin(destDirPath, "keycloak", "common", "resources", "node_modules");
|
const nodeModulesDirPath = pathJoin(destDirPath, "keycloak", "common", "resources", "node_modules");
|
||||||
|
|
||||||
const usedCommonResourceRelativeFilePaths = [
|
const toKeepPrefixes = [
|
||||||
...["patternfly.min.css", "patternfly-additions.min.css", "patternfly-additions.min.css"].map(fileBasename =>
|
...["patternfly.min.css", "patternfly-additions.min.css", "patternfly-additions.min.css"].map(fileBasename =>
|
||||||
pathJoin("patternfly", "dist", "css", fileBasename)
|
pathJoin("patternfly", "dist", "css", fileBasename)
|
||||||
),
|
),
|
||||||
...[
|
pathJoin("patternfly", "dist", "fonts")
|
||||||
"OpenSans-Light-webfont.woff2",
|
|
||||||
"OpenSans-Regular-webfont.woff2",
|
|
||||||
"OpenSans-Bold-webfont.woff2",
|
|
||||||
"OpenSans-Semibold-webfont.woff2",
|
|
||||||
"OpenSans-Bold-webfont.woff",
|
|
||||||
"OpenSans-Light-webfont.woff",
|
|
||||||
"OpenSans-Regular-webfont.woff",
|
|
||||||
"OpenSans-Semibold-webfont.woff",
|
|
||||||
"OpenSans-Regular-webfont.ttf",
|
|
||||||
"OpenSans-Light-webfont.ttf",
|
|
||||||
"OpenSans-Semibold-webfont.ttf",
|
|
||||||
"OpenSans-Bold-webfont.ttf"
|
|
||||||
].map(fileBasename => pathJoin("patternfly", "dist", "fonts", fileBasename))
|
|
||||||
];
|
];
|
||||||
|
|
||||||
transformCodebase({
|
transformCodebase({
|
||||||
"srcDirPath": nodeModulesDirPath,
|
"srcDirPath": nodeModulesDirPath,
|
||||||
"destDirPath": nodeModulesDirPath,
|
"destDirPath": nodeModulesDirPath,
|
||||||
"transformSourceCode": ({ sourceCode, fileRelativePath }) => {
|
"transformSourceCode": ({ sourceCode, fileRelativePath }) => {
|
||||||
if (!usedCommonResourceRelativeFilePaths.includes(fileRelativePath)) {
|
if (toKeepPrefixes.find(prefix => fileRelativePath.startsWith(prefix)) === undefined) {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
return { "modifiedSourceCode": sourceCode };
|
return { "modifiedSourceCode": sourceCode };
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user