Skip to content

Commit

Permalink
feat(mini-runner): 支持分包
Browse files Browse the repository at this point in the history
  • Loading branch information
luckyadam committed Jan 7, 2020
1 parent 8d6f9b3 commit 6240933
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 4 deletions.
4 changes: 0 additions & 4 deletions packages/taro-mini-runner/src/loaders/loader.ts

This file was deleted.

28 changes: 28 additions & 0 deletions packages/taro-mini-runner/src/plugins/MiniPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,33 @@ export default class MiniPlugin {
})
}

getSubPackages (appConfig) {
const subPackages = appConfig.subPackages || appConfig['subpackages']
if (subPackages && subPackages.length) {
subPackages.forEach(item => {
if (item.pages && item.pages.length) {
const root = item.root
item.pages.forEach(page => {
let pageItem = `${root}/${page}`
pageItem = pageItem.replace(/\/{2,}/g, '/')
let hasPageIn = false
this.pages.forEach(({ name }) => {
if (name === pageItem) {
hasPageIn = true
}
})
if (!hasPageIn) {
this.pages.add({
name: pageItem,
path: resolveScriptPath(path.join(this.sourceDir, pageItem))
})
}
})
}
})
}
}

getPages () {
const { buildAdapter } = this.options
const appEntry = this.appEntry
Expand All @@ -353,6 +380,7 @@ export default class MiniPlugin {
if (!appPages || appPages.length === 0) {
throw new Error('缺少页面')
}
this.getSubPackages(configObj)
taroFileTypeMap[this.appEntry] = {
type: PARSE_AST_TYPE.ENTRY,
config: configObj,
Expand Down

0 comments on commit 6240933

Please sign in to comment.