Skip to content

Commit ed9c835

Browse files
committed
perf(mp): 将子包依赖的静态资源内容打包到子包 assets.js 中
1 parent f38b2ca commit ed9c835

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

packages/uni-mp-vite/src/plugin/build.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,16 @@ function createMoveToVendorChunkFn(): GetManualChunk | undefined {
218218
// 处理资源文件
219219
if (DEFAULT_ASSETS_RE.test(filename)) {
220220
debugChunk('common/assets', normalizedId)
221+
const { subPackages } = getSubPackages()
222+
if (subPackages.length) {
223+
const relativePath = normalizePath(path.relative(inputDir, filename))
224+
const subPackageRoot = subPackages.find((subPackage) =>
225+
relativePath.startsWith(subPackage)
226+
)
227+
if (subPackageRoot) {
228+
return subPackageRoot + 'common/assets'
229+
}
230+
}
221231
return 'common/assets'
222232
}
223233
// 处理项目内的js,ts文件

0 commit comments

Comments
 (0)