@lark-apaas/fullstack-rspack-preset 1.0.14-alpha.tea.1 → 1.0.14
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/index.js +3 -2
- package/lib/module-alias/echartThemeUD.json +148 -0
- package/lib/preset.js +3 -2
- package/lib/rspack-plugins/slardar-performance-monitor-plugin.js +1 -40
- package/lib/utils/normalize-base-path.d.ts +6 -0
- package/lib/utils/normalize-base-path.js +14 -0
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -5,6 +5,7 @@ exports.defineConfig = createFullstackRspackConfig;
|
|
|
5
5
|
const webpack_merge_1 = require("webpack-merge");
|
|
6
6
|
const devtool_kits_1 = require("@lark-apaas/devtool-kits");
|
|
7
7
|
const preset_1 = require("./preset");
|
|
8
|
+
const normalize_base_path_1 = require("./utils/normalize-base-path");
|
|
8
9
|
/**
|
|
9
10
|
* 定义 Fullstack Rspack 配置
|
|
10
11
|
*
|
|
@@ -56,9 +57,9 @@ function createFullstackRspackConfig(overrides = {}) {
|
|
|
56
57
|
const needRoutes = process.env.NEED_ROUTES !== 'false'; // 默认 true
|
|
57
58
|
// 3. 处理路径配置
|
|
58
59
|
const clientBasePath = (0, devtool_kits_1.normalizeBasePath)(process.env.CLIENT_BASE_PATH || '/');
|
|
59
|
-
const publicPath = isDev
|
|
60
|
+
const publicPath = (0, normalize_base_path_1.normalizeBasePathWithoutTrailingSlash)(isDev
|
|
60
61
|
? process.env.CLIENT_BASE_PATH || '/'
|
|
61
|
-
: process.env.ASSETS_CDN_PATH || '/';
|
|
62
|
+
: process.env.ASSETS_CDN_PATH || '/');
|
|
62
63
|
// 4. 调用原有的 preset 函数生成基础配置
|
|
63
64
|
// 注意:enableInspector 目前在 preset 中由 isDev 控制,暂不暴露为独立参数
|
|
64
65
|
const baseConfig = (0, preset_1.createRecommendRspackConfig)({
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 1,
|
|
3
|
+
"themeName": "UD Theme Style",
|
|
4
|
+
"theme": {
|
|
5
|
+
"seriesCnt": "6",
|
|
6
|
+
"backgroundColor": "rgba(0,0,0,0)",
|
|
7
|
+
"titleColor": "#1f2329",
|
|
8
|
+
"subtitleColor": "#8f959e",
|
|
9
|
+
"textColorShow": false,
|
|
10
|
+
"textColor": "#333",
|
|
11
|
+
"markTextColor": "#ffffff",
|
|
12
|
+
"color": [
|
|
13
|
+
"#3370eb",
|
|
14
|
+
"#1bcebf",
|
|
15
|
+
"#ffc60a",
|
|
16
|
+
"#ed6d0c",
|
|
17
|
+
"#dca1e4",
|
|
18
|
+
"#25b2e5",
|
|
19
|
+
"#6dcdeb",
|
|
20
|
+
"#288fcb",
|
|
21
|
+
"#94b5f5",
|
|
22
|
+
"#8f61d1",
|
|
23
|
+
"#8f61d1",
|
|
24
|
+
"#bf78e9",
|
|
25
|
+
"#008280",
|
|
26
|
+
"#27ad8e",
|
|
27
|
+
"#7bc335"
|
|
28
|
+
],
|
|
29
|
+
"borderColor": "#dee0e3",
|
|
30
|
+
"borderWidth": 0,
|
|
31
|
+
"visualMapColor": ["#25b2e5", "#6dcdeb", "#288fcb"],
|
|
32
|
+
"legendTextColor": "#8f959e",
|
|
33
|
+
"kColor": "#fdc6c4",
|
|
34
|
+
"kColor0": "transparent",
|
|
35
|
+
"kBorderColor": "#f54a45",
|
|
36
|
+
"kBorderColor0": "#32a645",
|
|
37
|
+
"kBorderWidth": "2",
|
|
38
|
+
"lineWidth": "1",
|
|
39
|
+
"symbolSize": "6",
|
|
40
|
+
"symbol": "emptyCircle",
|
|
41
|
+
"symbolBorderWidth": "1",
|
|
42
|
+
"lineSmooth": true,
|
|
43
|
+
"graphLineWidth": 1,
|
|
44
|
+
"graphLineColor": "#dee0e3",
|
|
45
|
+
"mapLabelColor": "#000",
|
|
46
|
+
"mapLabelColorE": "#516b91",
|
|
47
|
+
"mapBorderColor": "#516b91",
|
|
48
|
+
"mapBorderColorE": "#516b91",
|
|
49
|
+
"mapBorderWidth": 0.5,
|
|
50
|
+
"mapBorderWidthE": 1,
|
|
51
|
+
"mapAreaColor": "#f3f3f3",
|
|
52
|
+
"mapAreaColorE": "#a5e7f0",
|
|
53
|
+
"axes": [
|
|
54
|
+
{
|
|
55
|
+
"type": "all",
|
|
56
|
+
"name": "通用坐标轴",
|
|
57
|
+
"axisLineShow": true,
|
|
58
|
+
"axisLineColor": "#dee0e3",
|
|
59
|
+
"axisTickShow": false,
|
|
60
|
+
"axisTickColor": "#333",
|
|
61
|
+
"axisLabelShow": true,
|
|
62
|
+
"axisLabelColor": "#8f959e",
|
|
63
|
+
"splitLineShow": true,
|
|
64
|
+
"splitLineColor": ["#dee0e3"],
|
|
65
|
+
"splitAreaShow": false,
|
|
66
|
+
"splitAreaColor": ["rgba(250,250,250,0.05)", "rgba(200,200,200,0.02)"]
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
"type": "category",
|
|
70
|
+
"name": "类目坐标轴",
|
|
71
|
+
"axisLineShow": true,
|
|
72
|
+
"axisLineColor": "#333",
|
|
73
|
+
"axisTickShow": true,
|
|
74
|
+
"axisTickColor": "#333",
|
|
75
|
+
"axisLabelShow": true,
|
|
76
|
+
"axisLabelColor": "#333",
|
|
77
|
+
"splitLineShow": false,
|
|
78
|
+
"splitLineColor": ["#ccc"],
|
|
79
|
+
"splitAreaShow": false,
|
|
80
|
+
"splitAreaColor": ["rgba(250,250,250,0.3)", "rgba(200,200,200,0.3)"]
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
"type": "value",
|
|
84
|
+
"name": "数值坐标轴",
|
|
85
|
+
"axisLineShow": true,
|
|
86
|
+
"axisLineColor": "#333",
|
|
87
|
+
"axisTickShow": true,
|
|
88
|
+
"axisTickColor": "#333",
|
|
89
|
+
"axisLabelShow": true,
|
|
90
|
+
"axisLabelColor": "#333",
|
|
91
|
+
"splitLineShow": true,
|
|
92
|
+
"splitLineColor": ["#ccc"],
|
|
93
|
+
"splitAreaShow": false,
|
|
94
|
+
"splitAreaColor": ["rgba(250,250,250,0.3)", "rgba(200,200,200,0.3)"]
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
"type": "log",
|
|
98
|
+
"name": "对数坐标轴",
|
|
99
|
+
"axisLineShow": true,
|
|
100
|
+
"axisLineColor": "#333",
|
|
101
|
+
"axisTickShow": true,
|
|
102
|
+
"axisTickColor": "#333",
|
|
103
|
+
"axisLabelShow": true,
|
|
104
|
+
"axisLabelColor": "#333",
|
|
105
|
+
"splitLineShow": true,
|
|
106
|
+
"splitLineColor": ["#ccc"],
|
|
107
|
+
"splitAreaShow": false,
|
|
108
|
+
"splitAreaColor": ["rgba(250,250,250,0.3)", "rgba(200,200,200,0.3)"]
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
"type": "time",
|
|
112
|
+
"name": "时间坐标轴",
|
|
113
|
+
"axisLineShow": true,
|
|
114
|
+
"axisLineColor": "#333",
|
|
115
|
+
"axisTickShow": true,
|
|
116
|
+
"axisTickColor": "#333",
|
|
117
|
+
"axisLabelShow": true,
|
|
118
|
+
"axisLabelColor": "#333",
|
|
119
|
+
"splitLineShow": true,
|
|
120
|
+
"splitLineColor": ["#ccc"],
|
|
121
|
+
"splitAreaShow": false,
|
|
122
|
+
"splitAreaColor": ["rgba(250,250,250,0.3)", "rgba(200,200,200,0.3)"]
|
|
123
|
+
}
|
|
124
|
+
],
|
|
125
|
+
"axisSeperateSetting": false,
|
|
126
|
+
"toolboxColor": "#8f959e",
|
|
127
|
+
"toolboxEmphasisColor": "#1f2329",
|
|
128
|
+
"tooltipAxisColor": "#dee0e3",
|
|
129
|
+
"tooltipAxisWidth": 1,
|
|
130
|
+
"timelineLineColor": "#336df4",
|
|
131
|
+
"timelineLineWidth": "-1",
|
|
132
|
+
"timelineItemColor": "#336df4",
|
|
133
|
+
"timelineItemColorE": "#1456f0",
|
|
134
|
+
"timelineCheckColor": "#1456f0",
|
|
135
|
+
"timelineCheckBorderColor": "#94b4ff",
|
|
136
|
+
"timelineItemBorderWidth": "0.5",
|
|
137
|
+
"timelineControlColor": "#336df4",
|
|
138
|
+
"timelineControlBorderColor": "#336df4",
|
|
139
|
+
"timelineControlBorderWidth": 0.5,
|
|
140
|
+
"timelineLabelColor": "#8f959e",
|
|
141
|
+
"datazoomBackgroundColor": "rgba(0,0,0,0)",
|
|
142
|
+
"datazoomDataColor": "rgba(255,255,255,0.3)",
|
|
143
|
+
"datazoomFillColor": "rgba(167,183,204,0.4)",
|
|
144
|
+
"datazoomHandleColor": "#a7b7cc",
|
|
145
|
+
"datazoomHandleWidth": "100",
|
|
146
|
+
"datazoomLabelColor": "#333"
|
|
147
|
+
}
|
|
148
|
+
}
|
package/lib/preset.js
CHANGED
|
@@ -16,6 +16,7 @@ const dev_server_snapdom_proxy_1 = require("./utils/dev-server-snapdom-proxy");
|
|
|
16
16
|
function createRecommendRspackConfig(options) {
|
|
17
17
|
const { isDev = true, enableReactRefresh = isDev, needRoutes = true, clientBasePath = '', publicPath = '', // 静态资源路径
|
|
18
18
|
} = options;
|
|
19
|
+
const assetsCDNPath = publicPath + '/';
|
|
19
20
|
const rootDir = process.cwd();
|
|
20
21
|
const serverPort = process.env.SERVER_PORT || '3000';
|
|
21
22
|
return {
|
|
@@ -152,7 +153,7 @@ function createRecommendRspackConfig(options) {
|
|
|
152
153
|
},
|
|
153
154
|
minify: false, // 关闭 html 压缩,导致数据注入异常
|
|
154
155
|
}),
|
|
155
|
-
//
|
|
156
|
+
// 性能监控插件
|
|
156
157
|
new slardar_performance_monitor_plugin_1.default(),
|
|
157
158
|
// 视图上下文注入插件
|
|
158
159
|
new view_context_injection_plugin_1.default(),
|
|
@@ -313,7 +314,7 @@ function createRecommendRspackConfig(options) {
|
|
|
313
314
|
},
|
|
314
315
|
},
|
|
315
316
|
output: {
|
|
316
|
-
publicPath,
|
|
317
|
+
publicPath: assetsCDNPath,
|
|
317
318
|
path: path_1.default.resolve(rootDir, 'dist/client'),
|
|
318
319
|
clean: false,
|
|
319
320
|
globalObject: 'this',
|
|
@@ -38,7 +38,6 @@ class SlardarPerformanceMonitorPlugin {
|
|
|
38
38
|
bid: this.options.bid,
|
|
39
39
|
globalName: this.options.globalName,
|
|
40
40
|
});
|
|
41
|
-
const teaSnippet = getTeaScriptContent();
|
|
42
41
|
if (!snippet)
|
|
43
42
|
return data;
|
|
44
43
|
// 创建 Slardar 脚本标签对象
|
|
@@ -48,13 +47,6 @@ class SlardarPerformanceMonitorPlugin {
|
|
|
48
47
|
innerHTML: snippet,
|
|
49
48
|
attributes: {},
|
|
50
49
|
};
|
|
51
|
-
// 创建 Tea 脚本标签对象
|
|
52
|
-
const teaTag = {
|
|
53
|
-
tagName: 'script',
|
|
54
|
-
voidTag: false,
|
|
55
|
-
innerHTML: teaSnippet,
|
|
56
|
-
attributes: {},
|
|
57
|
-
};
|
|
58
50
|
// 找到 main.js 的索引位置
|
|
59
51
|
const mainJsIndex = data.headTags.findIndex((tag) => tag.tagName === 'script' &&
|
|
60
52
|
tag.attributes &&
|
|
@@ -62,12 +54,11 @@ class SlardarPerformanceMonitorPlugin {
|
|
|
62
54
|
tag.attributes.src.includes('main.js'));
|
|
63
55
|
if (mainJsIndex !== -1) {
|
|
64
56
|
// 在 main.js 之前插入 Slardar 脚本
|
|
65
|
-
data.headTags.splice(mainJsIndex, 0, slardarTag
|
|
57
|
+
data.headTags.splice(mainJsIndex, 0, slardarTag);
|
|
66
58
|
}
|
|
67
59
|
else {
|
|
68
60
|
// 如果没找到 main.js,插入到 headTags 最前面
|
|
69
61
|
data.headTags.unshift(slardarTag);
|
|
70
|
-
data.headTags.unshift(teaTag);
|
|
71
62
|
}
|
|
72
63
|
return data;
|
|
73
64
|
});
|
|
@@ -115,33 +106,3 @@ function getSlardarScriptContent(option = {}) {
|
|
|
115
106
|
document.head.appendChild(performanceScript);
|
|
116
107
|
`;
|
|
117
108
|
}
|
|
118
|
-
// 获取 tea sdk 脚本
|
|
119
|
-
function getTeaScriptContent() {
|
|
120
|
-
return `
|
|
121
|
-
(function (win, export_obj) {
|
|
122
|
-
win['LogAnalyticsObject'] = export_obj;
|
|
123
|
-
if (!win[export_obj]) {
|
|
124
|
-
function _collect() {
|
|
125
|
-
_collect.q.push(arguments);
|
|
126
|
-
}
|
|
127
|
-
_collect.q = _collect.q || [];
|
|
128
|
-
win[export_obj] = _collect;
|
|
129
|
-
}
|
|
130
|
-
win[export_obj].l = +new Date();
|
|
131
|
-
})(window, 'collectEvent');
|
|
132
|
-
|
|
133
|
-
// 创建 tea sdk 脚本元素
|
|
134
|
-
const teaScript = document.createElement('script');
|
|
135
|
-
teaScript.src = 'https://lf3-cdn-tos.bytescm.com/obj/static/log-sdk/collect/5.1/collect.js';
|
|
136
|
-
teaScript.crossOrigin = 'anonymous';
|
|
137
|
-
teaScript.async = true;
|
|
138
|
-
|
|
139
|
-
// 添加错误处理
|
|
140
|
-
teaScript.onerror = function() {
|
|
141
|
-
console.warn('Failed to load Tea script');
|
|
142
|
-
};
|
|
143
|
-
|
|
144
|
-
// 将脚本添加到页面
|
|
145
|
-
document.head.appendChild(teaScript);
|
|
146
|
-
`;
|
|
147
|
-
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.normalizeBasePathWithoutTrailingSlash = normalizeBasePathWithoutTrailingSlash;
|
|
4
|
+
/**
|
|
5
|
+
* 标准化基础路径,确保以 '/' 开头且不包含 trailing slash
|
|
6
|
+
* @param basePath 原始基础路径
|
|
7
|
+
* @returns 标准化后的基础路径
|
|
8
|
+
*/
|
|
9
|
+
function normalizeBasePathWithoutTrailingSlash(basePath) {
|
|
10
|
+
const basePathWithoutTrailingSlash = basePath.endsWith('/')
|
|
11
|
+
? basePath.slice(0, -1)
|
|
12
|
+
: basePath;
|
|
13
|
+
return basePathWithoutTrailingSlash;
|
|
14
|
+
}
|