Skip to content

Commit f53ca81

Browse files
committed
fix(cli): alias 路径替换问题修复,close #1598
1 parent 7f6bea2 commit f53ca81

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

packages/taro-cli/src/util/index.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,11 +190,14 @@ exports.isAliasPath = function (name, pathAlias = {}) {
190190
if (prefixs.length === 0) {
191191
return false
192192
}
193-
return new RegExp(`^(${prefixs.join('|')})/`).test(name)
193+
return prefixs.includes(name) || (new RegExp(`^(${prefixs.join('|')})/`).test(name))
194194
}
195195

196196
exports.replaceAliasPath = function (filePath, name, pathAlias = {}) {
197197
const prefixs = Object.keys(pathAlias)
198+
if (prefixs.includes(name)) {
199+
return exports.promoteRelativePath(path.relative(filePath, pathAlias[name]))
200+
}
198201
const reg = new RegExp(`^(${prefixs.join('|')})/(.*)`)
199202
name = name.replace(reg, function (m, $1, $2) {
200203
return exports.promoteRelativePath(path.relative(filePath, path.join(pathAlias[$1], $2)))

0 commit comments

Comments
 (0)