Skip to content

Commit 6a69bc0

Browse files
author
zhengyanan18
committed
fix: 如果是编译H5组件模式&&onlyBundle为true,强制把唯一chunk的path改成入口path,确保产物唯一
1 parent 61035ce commit 6a69bc0

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

packages/taro-webpack5-runner/src/index.h5.ts

+11
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,17 @@ export default async function build (appPath: string, rawConfig: IH5BuildConfig)
4949

5050
const webpackConfig = combination.chain.toConfig()
5151
const config = combination.config
52+
// isBuildNativeComp && isOnlyBundle 为 true 时,强制把chunk的path设置为entry的key,确保产物只有一个js
53+
if (config.isBuildNativeComp && config.isOnlyBundle) {
54+
let entryKey:string = ''
55+
for (const key in webpackConfig.entry as webpack.EntryObject) {
56+
entryKey = key
57+
break
58+
}
59+
if (entryKey && webpackConfig.optimization?.splitChunks?.cacheGroups?.main) {
60+
webpackConfig.optimization.splitChunks.cacheGroups.main.name = entryKey
61+
}
62+
}
5263
const errorLevel = typeof config.compiler !== 'string' && config.compiler?.errorLevel || 0
5364

5465
try {

0 commit comments

Comments
 (0)