Don't replace process.env.PUBLIC_URL
This commit is contained in:
parent
217439d673
commit
6d62b5a150
@ -29,20 +29,6 @@ export function replaceImportsInJsCode_webpack(params: { jsCode: string; buildOp
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// d={NODE_ENV:"production",PUBLIC_URL:"/foo-bar",WDS_SOCKET_HOST
|
|
||||||
// d={NODE_ENV:"production",PUBLIC_URL:"",WDS_SOCKET_HOST
|
|
||||||
// ->
|
|
||||||
// ... PUBLIC_URL:window.kcContext.url.resourcesPath+"/build" ...
|
|
||||||
fixedJsCode = fixedJsCode.replace(
|
|
||||||
new RegExp(
|
|
||||||
`NODE_ENV:"production",PUBLIC_URL:"${
|
|
||||||
buildOptions.urlPathname !== undefined ? replaceAll(buildOptions.urlPathname.slice(0, -1), "/", "\\/") : ""
|
|
||||||
}"`,
|
|
||||||
"g"
|
|
||||||
),
|
|
||||||
`NODE_ENV:"production",PUBLIC_URL:window.${nameOfTheGlobal}.url.resourcesPath+"/${basenameOfTheKeycloakifyResourcesDir}"`
|
|
||||||
);
|
|
||||||
|
|
||||||
// Example: "static/ or "foo/bar/"
|
// Example: "static/ or "foo/bar/"
|
||||||
const staticDir = (() => {
|
const staticDir = (() => {
|
||||||
let out = pathRelative(buildOptions.reactAppBuildDirPath, buildOptions.assetsDirPath);
|
let out = pathRelative(buildOptions.reactAppBuildDirPath, buildOptions.assetsDirPath);
|
||||||
|
@ -361,40 +361,6 @@ describe("js replacer - webpack", () => {
|
|||||||
|
|
||||||
expect(isSameCode(fixedJsCode, fixedJsCodeExpected)).toBe(true);
|
expect(isSameCode(fixedJsCode, fixedJsCodeExpected)).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("replaceImportsInJsCode_webpack - 4", () => {
|
|
||||||
const jsCodeUntransformed = `d={NODE_ENV:"production",PUBLIC_URL:"",WDS_SOCKET_HOST`;
|
|
||||||
|
|
||||||
const { fixedJsCode } = replaceImportsInJsCode_webpack({
|
|
||||||
"jsCode": jsCodeUntransformed,
|
|
||||||
"buildOptions": {
|
|
||||||
"reactAppBuildDirPath": "/Users/someone/github/keycloakify-starter/build",
|
|
||||||
"assetsDirPath": "/Users/someone/github/keycloakify-starter/dist/build/static",
|
|
||||||
"urlPathname": undefined
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
const fixedJsCodeExpected = `d={NODE_ENV:"production",PUBLIC_URL:window.${nameOfTheGlobal}.url.resourcesPath+"/${basenameOfTheKeycloakifyResourcesDir}",WDS_SOCKET_HOST`;
|
|
||||||
|
|
||||||
expect(isSameCode(fixedJsCode, fixedJsCodeExpected)).toBe(true);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("replaceImportsInJsCode_webpack - 5", () => {
|
|
||||||
const jsCodeUntransformed = `d={NODE_ENV:"production",PUBLIC_URL:"/foo-bar",WDS_SOCKET_HOST`;
|
|
||||||
|
|
||||||
const { fixedJsCode } = replaceImportsInJsCode_webpack({
|
|
||||||
"jsCode": jsCodeUntransformed,
|
|
||||||
"buildOptions": {
|
|
||||||
"reactAppBuildDirPath": "/Users/someone/github/keycloakify-starter/build",
|
|
||||||
"assetsDirPath": "/Users/someone/github/keycloakify-starter/dist/build/static",
|
|
||||||
"urlPathname": "/foo-bar/"
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
const fixedJsCodeExpected = `d={NODE_ENV:"production",PUBLIC_URL:window.${nameOfTheGlobal}.url.resourcesPath+"/${basenameOfTheKeycloakifyResourcesDir}",WDS_SOCKET_HOST`;
|
|
||||||
|
|
||||||
expect(isSameCode(fixedJsCode, fixedJsCodeExpected)).toBe(true);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("css replacer", () => {
|
describe("css replacer", () => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user