Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(mini-runner): 支持分包
Browse files Browse the repository at this point in the history
luckyadam committed Dec 26, 2019
1 parent c73b6e8 commit 897930d
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
@@ -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
@@ -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,

0 comments on commit 897930d

Please sign in to comment.