Skip to content

Commit 011128a

Browse files
committed
Conditionally initializing ContentstackLivePreview if the livePreview is true
1 parent 0b11419 commit 011128a

File tree

1 file changed

+15
-13
lines changed

1 file changed

+15
-13
lines changed

src/sdk/entry.ts

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -32,19 +32,21 @@ if (customHostBaseUrl && isValidCustomHostUrl(customHostBaseUrl)) {
3232
Stack.setHost(customHostBaseUrl);
3333
}
3434

35-
// Setting LP if enabled
36-
ContentstackLivePreview.init({
37-
//@ts-ignore
38-
stackSdk: Stack,
39-
enable: ENV.LIVE_PREVIEW === "true",
40-
mode: "builder",
41-
stackDetails: {
42-
apiKey: ENV.API_KEY,
43-
},
44-
clientUrlParams:{
45-
host: ENV.APP_HOST
46-
}
47-
})?.catch((error) => console.error(error));
35+
if (ENV.LIVE_PREVIEW === "true") {
36+
// Setting LP if enabled
37+
ContentstackLivePreview.init({
38+
//@ts-ignore
39+
stackSdk: Stack,
40+
enable: ENV.LIVE_PREVIEW === "true",
41+
mode: "builder",
42+
stackDetails: {
43+
apiKey: ENV.API_KEY,
44+
},
45+
clientUrlParams: {
46+
host: ENV.APP_HOST
47+
}
48+
})?.catch((error) => console.error(error));
49+
}
4850

4951

5052
export const { onEntryChange } = ContentstackLivePreview;

0 commit comments

Comments
 (0)