-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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(mini): 修复 webpack4 中 wxml 和 wxs 的 loader 路径问题 #14427
Conversation
// 因此在 webpack4 中如果包含 sourceDir,证明是在 src 内的路径 | ||
if (resourcePath.includes(sourceDir)) { | ||
// 直接将 /xxx/src/yyy/zzz.wxml 转换成 yyy/zzz.wxml 即可 | ||
return resourcePath.replace(sourceDir + '/', '').replace(/node_modules/gi, 'npm') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里的路径拼接是否要兼容下 windows
? 我看原代码是 path.join
处理过
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
确实,晚点我兼容一下
环境:Taro 3.6.15 , React , 微信基础库3.0.1
Taro编译后:
|
这个问题什么时候可以合并到 release 主分支来使用?急用 |
taro 升级到 3.6.16 版本后,编译原生组件依然有问题,报错信息如下 原生组件编译结果 AdCustom/index.wxml |
@@ -92,7 +92,7 @@ export class MiniWebpackModule { | |||
generator: { | |||
filename ({ filename }) { | |||
const extname = path.extname(filename) | |||
return filename.replace(sourceRoot + '/', '').replace(extname, fileType.templ).replace(/node_modules/gi, 'npm') | |||
return filename.replace(sourceRoot + path.sep, '').replace(extname, fileType.templ).replace(/node_modules/gi, 'npm') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bigmeow @xuanzebin 这个兼容有问题,升级到3.6.16后,在Windows系统构建时,混合引入的原生组件在dist中放置的位置都有问题。
下面是在Windows下输出,filename是unix格式的路径,path.sep却是Windows专用的分隔符, filename的路径替换失效了
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
所以它本来是兼容的,特意兼容的 windows
结果反倒不兼容了?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bigmeow 是的
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
可能得麻烦你分别在 cmd
和 powershell
下都跑下代码,确认下是否都是这个问题
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bigmeow 我都试过了,效果是一样的。Debug看了下,webpack内部会把这里的filename转换成posix路径。
mark |
这个 PR 做了什么? (简要描述所做更改)
这个 PR 是什么类型? (至少选择一个)
这个 PR 涉及以下平台: