Skip to content

Commit

Permalink
fix: 如果是编译H5组件模式&&onlyBundle为true,强制把唯一chunk的path改成入口path,确保产物唯一
Browse files Browse the repository at this point in the history
  • Loading branch information
zhengyanan18 committed Dec 27, 2024
1 parent 61035ce commit 6a69bc0
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions packages/taro-webpack5-runner/src/index.h5.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,17 @@ export default async function build (appPath: string, rawConfig: IH5BuildConfig)

const webpackConfig = combination.chain.toConfig()
const config = combination.config
// isBuildNativeComp && isOnlyBundle 为 true 时,强制把chunk的path设置为entry的key,确保产物只有一个js
if (config.isBuildNativeComp && config.isOnlyBundle) {
let entryKey:string = ''
for (const key in webpackConfig.entry as webpack.EntryObject) {
entryKey = key
break
}
if (entryKey && webpackConfig.optimization?.splitChunks?.cacheGroups?.main) {
webpackConfig.optimization.splitChunks.cacheGroups.main.name = entryKey
}
}
const errorLevel = typeof config.compiler !== 'string' && config.compiler?.errorLevel || 0

try {
Expand Down

0 comments on commit 6a69bc0

Please sign in to comment.