@lark-apaas/fullstack-rspack-preset 1.0.19 → 1.0.20-alpha.app.1
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
|
@@ -12,6 +12,7 @@ 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
14
|
const view_context_injection_plugin_1 = __importDefault(require("./rspack-plugins/view-context-injection-plugin"));
|
|
15
|
+
const og_meta_injection_plugin_1 = __importDefault(require("./rspack-plugins/og-meta-injection-plugin"));
|
|
15
16
|
const dev_server_snapdom_proxy_1 = require("./utils/dev-server-snapdom-proxy");
|
|
16
17
|
function createRecommendRspackConfig(options) {
|
|
17
18
|
const { isDev = true, enableReactRefresh = isDev, needRoutes = true, clientBasePath = '', publicPath = '', // 静态资源路径
|
|
@@ -105,6 +106,9 @@ function createRecommendRspackConfig(options) {
|
|
|
105
106
|
},
|
|
106
107
|
},
|
|
107
108
|
experimental: {
|
|
109
|
+
// 避免 wasm 出现到根目录,统一放到 node_modules/.cache 目录下
|
|
110
|
+
cacheRoot: path_1.default.join(rootDir, './node_modules/.cache/swc'),
|
|
111
|
+
// 支持 styled-jsx 语法
|
|
108
112
|
plugins: [[require.resolve('@swc/plugin-styled-jsx'), {}]],
|
|
109
113
|
},
|
|
110
114
|
},
|
|
@@ -160,6 +164,8 @@ function createRecommendRspackConfig(options) {
|
|
|
160
164
|
new slardar_performance_monitor_plugin_1.default(),
|
|
161
165
|
// 视图上下文注入插件
|
|
162
166
|
new view_context_injection_plugin_1.default(),
|
|
167
|
+
// OG Meta 标签注入插件
|
|
168
|
+
new og_meta_injection_plugin_1.default(),
|
|
163
169
|
// 开发环境下,解析路由
|
|
164
170
|
isDev && needRoutes &&
|
|
165
171
|
new route_parser_plugin_1.default({
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
interface OgMetaInjectionPluginOptions {
|
|
2
|
+
customTags?: Array<{
|
|
3
|
+
property: string;
|
|
4
|
+
placeholder: string;
|
|
5
|
+
}>;
|
|
6
|
+
titlePlaceholder?: string;
|
|
7
|
+
faviconPlaceholder?: string;
|
|
8
|
+
}
|
|
9
|
+
declare class OgMetaInjectionPlugin {
|
|
10
|
+
private options;
|
|
11
|
+
private defaultOgTags;
|
|
12
|
+
private defaultTitlePlaceholder;
|
|
13
|
+
private defaultFaviconPlaceholder;
|
|
14
|
+
constructor(options?: OgMetaInjectionPluginOptions);
|
|
15
|
+
apply(compiler: any): void;
|
|
16
|
+
}
|
|
17
|
+
export default OgMetaInjectionPlugin;
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
class OgMetaInjectionPlugin {
|
|
4
|
+
constructor(options) {
|
|
5
|
+
// 默认需要处理的 OG 标签配置
|
|
6
|
+
this.defaultOgTags = [
|
|
7
|
+
{ property: 'og:title', placeholder: '{{appName}}' },
|
|
8
|
+
{ property: 'og:description', placeholder: '{{appDescription}}' },
|
|
9
|
+
{ property: 'og:image', placeholder: '{{appAvatar}}' },
|
|
10
|
+
{ property: 'og:url', placeholder: '{{currentUrl}}' },
|
|
11
|
+
];
|
|
12
|
+
// 默认 title 占位符
|
|
13
|
+
this.defaultTitlePlaceholder = '{{appName}}';
|
|
14
|
+
// 默认 favicon 占位符
|
|
15
|
+
this.defaultFaviconPlaceholder = '{{appAvatar}}';
|
|
16
|
+
this.options = options || {};
|
|
17
|
+
}
|
|
18
|
+
apply(compiler) {
|
|
19
|
+
compiler.hooks.compilation.tap('OgMetaInjectionPlugin', (compilation) => {
|
|
20
|
+
try {
|
|
21
|
+
// 从 compiler.webpack 或 compiler.rspack 获取 HtmlRspackPlugin
|
|
22
|
+
// 这样可以避免在 npm link 环境下的模块解析问题
|
|
23
|
+
let HtmlPlugin;
|
|
24
|
+
try {
|
|
25
|
+
// 尝试从 compiler 中获取 rspack
|
|
26
|
+
const rspack = compiler.webpack || compiler.rspack || compiler.constructor.webpack;
|
|
27
|
+
if (rspack && rspack.HtmlRspackPlugin) {
|
|
28
|
+
HtmlPlugin = rspack.HtmlRspackPlugin;
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
// 降级到 require,但这在 npm link 下可能失败
|
|
32
|
+
try {
|
|
33
|
+
HtmlPlugin = require('html-webpack-plugin');
|
|
34
|
+
}
|
|
35
|
+
catch (e2) {
|
|
36
|
+
console.warn('OgMetaInjectionPlugin: HtmlRspackPlugin not found');
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
catch (e) {
|
|
42
|
+
console.warn('OgMetaInjectionPlugin: Failed to get HtmlRspackPlugin');
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
const hooks = HtmlPlugin.getHooks(compilation);
|
|
46
|
+
// 使用 alterAssetTagGroups 钩子,在标签数组层面操作
|
|
47
|
+
hooks.alterAssetTagGroups.tap('OgMetaInjectionPlugin', (data) => {
|
|
48
|
+
// 1. 处理 OG Meta 标签
|
|
49
|
+
const ogTags = this.options.customTags || this.defaultOgTags;
|
|
50
|
+
// 遍历每个 OG 标签配置
|
|
51
|
+
ogTags.forEach(({ property, placeholder }) => {
|
|
52
|
+
// 检查是否已经存在该 property 的 meta 标签
|
|
53
|
+
const existingMetaIndex = data.headTags.findIndex((tag) => tag.tagName === 'meta' &&
|
|
54
|
+
tag.attributes &&
|
|
55
|
+
tag.attributes.property === property);
|
|
56
|
+
if (existingMetaIndex !== -1) {
|
|
57
|
+
// 如果存在,更新其 content 为占位符
|
|
58
|
+
data.headTags[existingMetaIndex].attributes.content = placeholder;
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
// 如果不存在,创建新的 meta 标签并添加到 headTags
|
|
62
|
+
const newMetaTag = {
|
|
63
|
+
tagName: 'meta',
|
|
64
|
+
voidTag: true,
|
|
65
|
+
attributes: {
|
|
66
|
+
property: property,
|
|
67
|
+
content: placeholder,
|
|
68
|
+
},
|
|
69
|
+
};
|
|
70
|
+
// 将新标签插入到 headTags 的开头
|
|
71
|
+
data.headTags.unshift(newMetaTag);
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
// 2. 处理 <title> 标签
|
|
75
|
+
const titlePlaceholder = this.options.titlePlaceholder || this.defaultTitlePlaceholder;
|
|
76
|
+
const titleTagIndex = data.headTags.findIndex((tag) => tag.tagName === 'title');
|
|
77
|
+
if (titleTagIndex !== -1) {
|
|
78
|
+
// 如果存在 title 标签,更新其内容为占位符
|
|
79
|
+
data.headTags[titleTagIndex].innerHTML = titlePlaceholder;
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
// 如果不存在,创建新的 title 标签
|
|
83
|
+
const newTitleTag = {
|
|
84
|
+
tagName: 'title',
|
|
85
|
+
voidTag: false,
|
|
86
|
+
innerHTML: titlePlaceholder,
|
|
87
|
+
attributes: {},
|
|
88
|
+
};
|
|
89
|
+
// 将 title 标签插入到 headTags 的开头
|
|
90
|
+
data.headTags.unshift(newTitleTag);
|
|
91
|
+
}
|
|
92
|
+
// 3. 处理 <link rel="icon"> 标签
|
|
93
|
+
const faviconPlaceholder = this.options.faviconPlaceholder || this.defaultFaviconPlaceholder;
|
|
94
|
+
const iconTagIndex = data.headTags.findIndex((tag) => tag.tagName === 'link' &&
|
|
95
|
+
tag.attributes &&
|
|
96
|
+
(tag.attributes.rel === 'icon' || tag.attributes.rel === 'shortcut icon'));
|
|
97
|
+
if (iconTagIndex !== -1) {
|
|
98
|
+
// 如果存在 icon 标签,更新其 href 为占位符
|
|
99
|
+
data.headTags[iconTagIndex].attributes.href = faviconPlaceholder;
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
// 如果不存在,创建新的 icon 标签
|
|
103
|
+
const newIconTag = {
|
|
104
|
+
tagName: 'link',
|
|
105
|
+
voidTag: true,
|
|
106
|
+
attributes: {
|
|
107
|
+
rel: 'icon',
|
|
108
|
+
href: faviconPlaceholder,
|
|
109
|
+
},
|
|
110
|
+
};
|
|
111
|
+
// 将 icon 标签插入到 headTags
|
|
112
|
+
data.headTags.unshift(newIconTag);
|
|
113
|
+
}
|
|
114
|
+
return data;
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
catch (error) {
|
|
118
|
+
console.error('Error in OgMetaInjectionPlugin:', error);
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
exports.default = OgMetaInjectionPlugin;
|
|
@@ -70,5 +70,13 @@ function getViewContextScriptContent() {
|
|
|
70
70
|
window.userId = "{{userId}}";
|
|
71
71
|
window.tenantId = "{{tenantId}}";
|
|
72
72
|
window.appId = "{{appId}}";
|
|
73
|
+
const appInfo = {
|
|
74
|
+
name: "{{appName}}",
|
|
75
|
+
avatar: "{{appAvatar}}",
|
|
76
|
+
description: "{{appDescription}}",
|
|
77
|
+
};
|
|
78
|
+
if (appInfo.name) {
|
|
79
|
+
window._appInfo = appInfo;
|
|
80
|
+
}
|
|
73
81
|
`;
|
|
74
82
|
}
|
package/package.json
CHANGED
|
@@ -1,148 +0,0 @@
|
|
|
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
|
-
}
|