Skip to content

Commit

Permalink
fix: 🩹 兼容处理pages.json中以斜杠为结尾的子包根路径写法
Browse files Browse the repository at this point in the history
  • Loading branch information
Vanisper committed Dec 21, 2024
1 parent 51c8308 commit 03108e7
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion examples/src/pages.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
]
},
{
"root": "pages-sub-async",
"root": "pages-sub-async/",
"pages": [
{
"path": "index",
Expand Down
3 changes: 2 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ export function UniappSubPackagesOptimization(): Plugin {
const subPkgsInfo: ISubPkgsInfo[] = Object.values(UNI_SUBPACKAGES)
const normalFilter = ({ independent }: ISubPkgsInfo) => !independent
const independentFilter = ({ independent }: ISubPkgsInfo) => independent
const map2Root = ({ root }: ISubPkgsInfo) => `${root}/`
/** 先去除尾部的`/`,再添加`/`,兼容pages.json中以`/`结尾的路径 */
const map2Root = ({ root }: ISubPkgsInfo) => `${root.replace(/\/$/, '')}/`
const subPackageRoots = subPkgsInfo.map(map2Root)
const normalSubPackageRoots = subPkgsInfo.filter(normalFilter).map(map2Root)
const independentSubpackageRoots = subPkgsInfo.filter(independentFilter).map(map2Root)
Expand Down

0 comments on commit 03108e7

Please sign in to comment.