Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix #15919 #15894

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions packages/taro-mini-runner/src/webpack/chain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -440,15 +440,15 @@ export const getModule = (appPath: string, {
// 因此在 webpack4 中如果包含 sourceDir,证明是在 src 内的路径
if (resourcePath.includes(sourceDir)) {
// 直接将 /xxx/src/yyy/zzz.wxml 转换成 yyy/zzz.wxml 即可
return resourcePath.replace(sourceDir + '/', '').replace(/node_modules/gi, 'npm')
return resourcePath.replace(path.join(sourceDir, path.sep), '').replace(/node_modules/gi, 'npm')
} else {
// 否则,证明是外层,存在一下两种可能
// resourcePath /xxx/uuu/aaa/node_modules/yy/zzz.wxml
// --> result: npm/yy/zzz.wxml

// resourcePath /xxx/uuu/aaa/bbb/abc/yy/zzz.wxml
// --> result: bbb/abc/yy/zzz.wxml
return resourcePath.replace(appPath + '/', '').replace(/node_modules/gi, 'npm')
return resourcePath.replace(path.join(appPath, path.sep), '').replace(/node_modules/gi, 'npm')
}
},
context: sourceDir
Expand All @@ -460,9 +460,9 @@ export const getModule = (appPath: string, {
useRelativePath: true,
name: (resourcePath) => {
if (resourcePath.includes(sourceDir)) {
return resourcePath.replace(sourceDir + '/', '').replace(/node_modules/gi, 'npm')
return resourcePath.replace(path.join(sourceDir, path.sep), '').replace(/node_modules/gi, 'npm')
} else {
return resourcePath.replace(appPath + '/', '').replace(/node_modules/gi, 'npm')
return resourcePath.replace(path.join(appPath, path.sep), '').replace(/node_modules/gi, 'npm')
}
},
context: sourceDir
Expand Down
Loading