Skip to content

Commit

Permalink
feat(mini-runner): 支持分包
Browse files Browse the repository at this point in the history
  • Loading branch information
luckyadam committed Dec 31, 2019
1 parent 8578d17 commit 6abb72b
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
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 6abb72b

Please sign in to comment.