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

没有编译的老旧项目加载会出问题 #11

Closed
18610509683 opened this issue Jul 13, 2022 · 4 comments
Closed

没有编译的老旧项目加载会出问题 #11

18610509683 opened this issue Jul 13, 2022 · 4 comments

Comments

@18610509683
Copy link

相对路径会访问主应用服务器端的

@yiludege
Copy link
Collaborator

1、对于js沙箱,子应用的 iframe 会设置 base 标签,所以在里面跑的script和接口请求相对都能够正确修正
2、对于dom沙箱,框架劫持了img、a、source、link、script等元素的原型方法,当这些元素设置地址的时候会将相对地址改写成绝对地址
3、对于在css内部的比如background-image: url('./images/my-image.png')框架确实没有处理,可以参考

如果确实还有问题,可以采用插件,其中html-loader、js-loader、css-loader可以将html、js和css在运行时做替换,比如正则匹配找出相对地址链接替换成绝对地址链接从而避免去改动子应用的代码

@18610509683
Copy link
Author

还有就是子应用的静态定位会出问题,定位到主应用里

@yiludege
Copy link
Collaborator

这个方便给个复现demo吗?我这边没有复现到具体问题

@yiludege
Copy link
Collaborator

yiludege commented Aug 8, 2022

3、对于在css内部的比如background-image: url('./images/my-image.png')框架确实没有处理

@18610509683 这个问题框架也已经处理了,详见 #35

@yiludege yiludege closed this as completed Aug 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants