@lark-apaas/fullstack-rspack-preset 1.0.33-alpha.2 → 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
@@ -8,10 +8,10 @@ const path_1 = __importDefault(require("path"));
8
8
  const core_1 = __importDefault(require("@rspack/core"));
9
9
  const devtool_kits_1 = require("@lark-apaas/devtool-kits");
10
10
  const plugin_react_refresh_1 = __importDefault(require("@rspack/plugin-react-refresh"));
11
- const dotenv_1 = __importDefault(require("dotenv"));
12
11
  const dev_server_listener_1 = require("./utils/dev-server-listener");
13
12
  const route_parser_plugin_1 = __importDefault(require("./rspack-plugins/route-parser-plugin"));
14
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"));
15
15
  const view_context_injection_plugin_1 = __importDefault(require("./rspack-plugins/view-context-injection-plugin"));
16
16
  const og_meta_injection_plugin_1 = __importDefault(require("./rspack-plugins/og-meta-injection-plugin"));
17
17
  const dev_server_snapdom_proxy_1 = require("./utils/dev-server-snapdom-proxy");
@@ -25,18 +25,11 @@ function sendBackendUnavailable502(_err, _req, res) {
25
25
  res.end(JSON.stringify({ error: 'Bad Gateway', message: 'Backend service is not running' }));
26
26
  }
27
27
  function createRecommendRspackConfig(options) {
28
- try {
29
- dotenv_1.default.config();
30
- }
31
- catch (_e) {
32
- void _e;
33
- }
34
28
  const { isDev = true, enableReactRefresh = isDev, needRoutes = true, clientBasePath = '', publicPath = '', // 静态资源路径
35
29
  } = options;
36
30
  const assetsCDNPath = publicPath + '/';
37
31
  const rootDir = process.cwd();
38
32
  const serverPort = process.env.SERVER_PORT || '3000';
39
- const windowEnvironment = mapToWindowEnvironment(process.env.FORCE_FRAMEWORK_ENVIRONMENT);
40
33
  return {
41
34
  mode: isDev ? 'development' : 'production',
42
35
  cache: false,
@@ -178,10 +171,11 @@ function createRecommendRspackConfig(options) {
178
171
  },
179
172
  minify: false, // 关闭 html 压缩,导致数据注入异常
180
173
  }),
174
+ new environment_injection_plugin_1.default(),
181
175
  // 性能监控&tea埋点sdk插件
182
176
  new slardar_performance_monitor_plugin_1.default(),
183
177
  // 视图上下文注入插件
184
- new view_context_injection_plugin_1.default({ environment: windowEnvironment }),
178
+ new view_context_injection_plugin_1.default(),
185
179
  // OG Meta 标签注入插件
186
180
  new og_meta_injection_plugin_1.default(),
187
181
  // 开发环境下,解析路由
@@ -347,13 +341,3 @@ function createRecommendRspackConfig(options) {
347
341
  },
348
342
  };
349
343
  }
350
- function mapToWindowEnvironment(input) {
351
- const value = (input || '').trim().toLowerCase();
352
- if (value === 'boe')
353
- return 'staging';
354
- if (value === 'pre')
355
- return 'gray';
356
- if (value === 'online')
357
- return 'online';
358
- return '';
359
- }
@@ -52,7 +52,7 @@ function mapToWindowEnvironment(input) {
52
52
  return 'staging';
53
53
  if (value === 'pre')
54
54
  return 'gray';
55
- if (value === 'prod')
55
+ if (value === 'online')
56
56
  return 'online';
57
57
  return '';
58
58
  }
@@ -1,5 +1,4 @@
1
1
  interface ViewContextInjectionPluginOptions {
2
- environment?: string;
3
2
  }
4
3
  declare class ViewContextInjectionPlugin {
5
4
  private options;
@@ -38,7 +38,7 @@ class ViewContextInjectionPlugin {
38
38
  const viewContextTag = {
39
39
  tagName: 'script',
40
40
  voidTag: false,
41
- innerHTML: getViewContextScriptContent(this.options.environment),
41
+ innerHTML: getViewContextScriptContent(),
42
42
  attributes: {},
43
43
  };
44
44
  // 找到 main.js 的索引位置
@@ -64,9 +64,8 @@ class ViewContextInjectionPlugin {
64
64
  }
65
65
  }
66
66
  exports.default = ViewContextInjectionPlugin;
67
- function getViewContextScriptContent(environment) {
67
+ function getViewContextScriptContent() {
68
68
  return `
69
- window.ENVIRONMENT = ${JSON.stringify(environment ?? '')};
70
69
  window.csrfToken = "{{csrfToken}}";
71
70
  window.userId = "{{userId}}";
72
71
  window.tenantId = "{{tenantId}}";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lark-apaas/fullstack-rspack-preset",
3
- "version": "1.0.33-alpha.2",
3
+ "version": "1.0.33-alpha.3",
4
4
  "files": [
5
5
  "lib",
6
6
  "patches",