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 9485c29

Browse files
committed
feat(webpack5-react): support __version__ param in html
1 parent e3cdce4 commit 9485c29

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
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.2.1",
3+
"version": "1.2.2",
44
"description": "console toolkit plugin for base react app",
55
"main": "lib/index.js",
66
"scripts": {

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,9 @@ export const common = (config: Chain, options: BreezrReactOptions = defaultOptio
9696
return;
9797
}
9898

99+
const env = getEnv();
100+
const [, version = ''] = env.gitBranch?.split('/') || [];
101+
99102
// @ts-ignore
100103
if (options.useHappyPack) {
101104
error('don\'t support useHappyPack');
@@ -140,7 +143,7 @@ export const common = (config: Chain, options: BreezrReactOptions = defaultOptio
140143
reactCssModules: true,
141144
reactCssModulesContext: src,
142145
// 只有在构建的时候才开启转义,否则 .mjs 被转义后,会导致 ReactHotLoader 中兼容 esModule 的方法失效,抛出异常:module is not defined
143-
es5ImcompatibleVersions: getEnv().isProd() && (es5ImcompatibleVersions || es5IncompatibleVersions),
146+
es5ImcompatibleVersions: env.isProd() && (es5ImcompatibleVersions || es5IncompatibleVersions),
144147
exclude: babelExclude,
145148
windRc: babelPluginWindRc,
146149
useBuiltIns: babelUseBuiltIns,
@@ -189,7 +192,8 @@ export const common = (config: Chain, options: BreezrReactOptions = defaultOptio
189192
inject: htmInject,
190193
scriptLoading: options.htmlScriptLoading ? options.htmlScriptLoading : 'blocking',
191194
templateParameters: {
192-
__dev__: getEnv().isDev()
195+
__dev__: env.isDev(),
196+
__version__: version,
193197
},
194198
});
195199
htmlInjectPlugin(config, {
@@ -198,7 +202,7 @@ export const common = (config: Chain, options: BreezrReactOptions = defaultOptio
198202
});
199203
}
200204

201-
if (analyze && !getEnv().isCloudBuild()) {
205+
if (analyze && !env.isCloudBuild()) {
202206
analyzerPlugin(config);
203207
}
204208

0 commit comments

Comments
(0)

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