@lark-apaas/fullstack-rspack-preset 1.0.33-alpha.4 → 1.0.33-alpha.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -65,12 +65,17 @@ class ViewContextInjectionPlugin {
|
|
|
65
65
|
}
|
|
66
66
|
exports.default = ViewContextInjectionPlugin;
|
|
67
67
|
function getViewContextScriptContent() {
|
|
68
|
+
const fallbackEnvironment = mapToWindowEnvironment(process.env.FORCE_FRAMEWORK_ENVIRONMENT);
|
|
68
69
|
return `
|
|
69
70
|
window.csrfToken = "{{csrfToken}}";
|
|
70
71
|
window.userId = "{{userId}}";
|
|
71
72
|
window.tenantId = "{{tenantId}}";
|
|
72
73
|
window.appId = "{{appId}}";
|
|
73
|
-
|
|
74
|
+
(() => {
|
|
75
|
+
const templateValue = "{{environment}}";
|
|
76
|
+
const resolved = templateValue !== "{{environment}}" ? templateValue : ${JSON.stringify(fallbackEnvironment)};
|
|
77
|
+
window.ENVIRONMENT = resolved;
|
|
78
|
+
})();
|
|
74
79
|
const appInfo = {
|
|
75
80
|
name: "{{appName}}",
|
|
76
81
|
avatar: "{{{appAvatar}}}",
|
|
@@ -81,3 +86,13 @@ function getViewContextScriptContent() {
|
|
|
81
86
|
}
|
|
82
87
|
`;
|
|
83
88
|
}
|
|
89
|
+
function mapToWindowEnvironment(input) {
|
|
90
|
+
const value = (input || '').trim().toLowerCase();
|
|
91
|
+
if (value === 'boe')
|
|
92
|
+
return 'staging';
|
|
93
|
+
if (value === 'pre')
|
|
94
|
+
return 'gray';
|
|
95
|
+
if (value === 'online')
|
|
96
|
+
return 'online';
|
|
97
|
+
return '';
|
|
98
|
+
}
|