Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Aug 5, 2025. It is now read-only.

Commit 04a46de

Browse files
committed
feat(plugin-react): emit html for oneConsole
1 parent 7b9fafe commit 04a46de

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

‎packages/plugin-react/package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@alicloud/console-toolkit-plugin-react",
3-
"version": "1.4.4",
3+
"version": "1.5.0",
44
"description": "console toolkit plugin for base react app",
55
"main": "lib/index.js",
66
"scripts": {
@@ -19,6 +19,7 @@
1919
"devDependencies": {
2020
"@types/autoprefixer": "^9.1.1",
2121
"@types/chai": "^4.1.7",
22+
"@types/fs-extra": "^11.0.4",
2223
"@types/html-webpack-plugin": "^3.2.0",
2324
"@types/jest": "^24.0.18",
2425
"@types/lodash": "^4.14.116",
@@ -49,6 +50,7 @@
4950
"error-overlay-webpack-plugin": "^0.4.0",
5051
"es5-imcompatible-versions": "^0.1.62",
5152
"file-loader": "^4.2.0",
53+
"fs-extra": "^11.3.0",
5254
"html-webpack-plugin": "^3.2.0",
5355
"less": "^3.9.0",
5456
"less-loader": "^6.2.0",

‎packages/plugin-react/src/webpack/common.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ export const common = (config: Chain, options: BreezrReactOptions = defaultOptio
173173
if (!disableHtml) {
174174
const htmlData = api.dispatchSync<HtmlData>('getHtmlData');
175175

176+
// generate index.html
176177
htmlPlugin(config, {
177178
minify: { // 压缩HTML文件
178179
removeComments: true, // 移除HTML中的注释
@@ -195,6 +196,7 @@ export const common = (config: Chain, options: BreezrReactOptions = defaultOptio
195196
};
196197
},
197198
});
199+
198200
htmlInjectPlugin(config, {
199201
data: htmlData,
200202
htmlXmlMode,

‎packages/plugin-react/src/webpack/plugins/htmlInject.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import * as webpack from 'webpack';
22
import * as url from 'url';
3+
import * as fs from 'fs-extra';
4+
import * as path from 'path';
35
import * as cheerio from 'cheerio';
46
import * as Chain from 'webpack-chain';
57
import type { CheerioAPI } from 'cheerio';
@@ -93,6 +95,17 @@ class HtmlInjectPlugin {
9395
data.html = $.html();
9496
callback();
9597
});
98+
99+
// @ts-ignore
100+
compilation.hooks.htmlWebpackPluginAfterHtmlProcessing.tapAsync('HtmlInjectPlugin', (data, callback) => {
101+
if (data.html) {
102+
const oneHtmlPath = path.resolve(compiler.options.output?.path || '', 'one.html');
103+
fs.ensureFileSync(oneHtmlPath);
104+
fs.writeFileSync(oneHtmlPath, data.html.replace(/\.alicdn.com/g, '.{{{MAIN_RESOURCE_CDN}}}.com'));
105+
}
106+
107+
callback();
108+
});
96109
});
97110
}
98111

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /