@lark-apaas/fullstack-rspack-preset 1.0.33-alpha.1 → 1.0.33-alpha.3
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.
package/lib/preset.js
CHANGED
|
@@ -11,6 +11,7 @@ const plugin_react_refresh_1 = __importDefault(require("@rspack/plugin-react-ref
|
|
|
11
11
|
const dev_server_listener_1 = require("./utils/dev-server-listener");
|
|
12
12
|
const route_parser_plugin_1 = __importDefault(require("./rspack-plugins/route-parser-plugin"));
|
|
13
13
|
const slardar_performance_monitor_plugin_1 = __importDefault(require("./rspack-plugins/slardar-performance-monitor-plugin"));
|
|
14
|
+
const environment_injection_plugin_1 = __importDefault(require("./rspack-plugins/environment-injection-plugin"));
|
|
14
15
|
const view_context_injection_plugin_1 = __importDefault(require("./rspack-plugins/view-context-injection-plugin"));
|
|
15
16
|
const og_meta_injection_plugin_1 = __importDefault(require("./rspack-plugins/og-meta-injection-plugin"));
|
|
16
17
|
const dev_server_snapdom_proxy_1 = require("./utils/dev-server-snapdom-proxy");
|
|
@@ -170,6 +171,7 @@ function createRecommendRspackConfig(options) {
|
|
|
170
171
|
},
|
|
171
172
|
minify: false, // 关闭 html 压缩,导致数据注入异常
|
|
172
173
|
}),
|
|
174
|
+
new environment_injection_plugin_1.default(),
|
|
173
175
|
// 性能监控&tea埋点sdk插件
|
|
174
176
|
new slardar_performance_monitor_plugin_1.default(),
|
|
175
177
|
// 视图上下文注入插件
|
|
@@ -65,9 +65,7 @@ class ViewContextInjectionPlugin {
|
|
|
65
65
|
}
|
|
66
66
|
exports.default = ViewContextInjectionPlugin;
|
|
67
67
|
function getViewContextScriptContent() {
|
|
68
|
-
const windowEnvironment = mapToWindowEnvironment(process.env.FORCE_FRAMEWORK_ENVIRONMENT);
|
|
69
68
|
return `
|
|
70
|
-
window.ENVIRONMENT = ${JSON.stringify(windowEnvironment)};
|
|
71
69
|
window.csrfToken = "{{csrfToken}}";
|
|
72
70
|
window.userId = "{{userId}}";
|
|
73
71
|
window.tenantId = "{{tenantId}}";
|
|
@@ -82,13 +80,3 @@ function getViewContextScriptContent() {
|
|
|
82
80
|
}
|
|
83
81
|
`;
|
|
84
82
|
}
|
|
85
|
-
function mapToWindowEnvironment(input) {
|
|
86
|
-
const value = (input || '').trim().toLowerCase();
|
|
87
|
-
if (value === 'boe')
|
|
88
|
-
return 'staging';
|
|
89
|
-
if (value === 'pre')
|
|
90
|
-
return 'gray';
|
|
91
|
-
if (value === 'online ')
|
|
92
|
-
return 'online';
|
|
93
|
-
return '';
|
|
94
|
-
}
|