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 7b9fafe

Browse files
committed
feat(webpack5-react): emit one.html
1 parent 11930ea commit 7b9fafe

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

‎packages/plugin-webpack5-react/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@alicloud/console-toolkit-plugin-webpack5-react",
3-
"version": "1.3.2",
3+
"version": "1.4.0",
44
"description": "console toolkit plugin for base react app",
55
"main": "lib/index.js",
66
"scripts": {

‎packages/plugin-webpack5-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 '@gem-mine/webpack-chain';
57
import * as HtmlWebpackPlugin from 'html-webpack-plugin';
@@ -84,6 +86,17 @@ class HtmlInjectPlugin {
8486
data.html = $.html();
8587
callback();
8688
});
89+
90+
// @ts-ignore
91+
HtmlWebpackPlugin.getHooks(compilation).beforeEmit.tapAsync('HtmlInjectPlugin', (data, callback) => {
92+
if (data.html) {
93+
const oneHtmlPath = path.resolve(compilation.options.output.path || '', 'one.html');
94+
fs.ensureFileSync(oneHtmlPath);
95+
fs.writeFileSync(oneHtmlPath, data.html.replace(/\.alicdn.com/g, '.{{{MAIN_RESOURCE_CDN}}}.com'));
96+
}
97+
98+
callback();
99+
});
87100
});
88101
}
89102

‎packages/plugin-webpack5-react/src/webpack/rules/file.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export const file = (config: Chain, options: BreezrReactOptions) => {
1717
});
1818

1919
rule
20+
.type('javascript/auto')
2021
.use('url-loader')
2122
.loader(require.resolve('url-loader'))
2223
.options({

0 commit comments

Comments
(0)

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