diff --git a/packages/taro-cli/src/rn/transformJS.js b/packages/taro-cli/src/rn/transformJS.js index 7d8f1118a6bc..92a04dbceab2 100644 --- a/packages/taro-cli/src/rn/transformJS.js +++ b/packages/taro-cli/src/rn/transformJS.js @@ -67,8 +67,16 @@ function getClassPropertyVisitor ({filePath, pages, iconPaths, isEntryFile}) { const value = node.value // if (key.name !== 'pages' || !t.isArrayExpression(value)) return if (key.name === 'pages' && t.isArrayExpression(value)) { + // 分包 + let root = '' + const rootNode = astPath.parent.properties.find(v => { + return v.key.name === 'root' + }) + root = rootNode ? rootNode.value.value : '' + value.elements.forEach(v => { - pages.push(v.value) + const pagePath = `${root}/${v.value}`.replace(/\/{2,}/g, '/') + pages.push(pagePath.replace(/^\//, '')) }) astPath.remove() }