Skip to content

修复相对路径资源无法正常引入的bug #19

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

Merged
merged 2 commits into from
May 17, 2018

Conversation

steinslin
Copy link
Member

@aOrz 那个bug没有重现,转base64后应该是没有再copy的,可能是之前留下的,可以先把dist remove掉再试试看有没被copy。另外存在一个bug,在windows下路径解析错误,这里修复了。

if (firstChar === '.') {
// 资源路径
var assetPath = path.resolve(path.dirname(fileOptions.resourcePath), value)
// 小于limit的资源转base64
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

对啦,在小程序里没有必要转 base64 啊。。。一整个就一个离线包,base64 反而可能影响解析速度

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

主要是背景图还有字体啥的本地只能用 base64 格式的

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

好像是没什么必要,背景图那些这里不会处理到,可以把limit默认设置为0吧

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

所以背景图和字体还是不会被转换吗?有这个需求的人好像还挺多

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

在css中引入的背景图是url-loader处理的,如果只有base64支持,可以把url-loader的配置limit调大

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

背景图我记得好像没问题,字体没试过,理论上应该也可以,不知道为什么之前好多人说这个问题。。

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里主要是处理 img 标签这类引用相对资源的话,确实不是很有必要转 base64

Copy link
Member

@F-loat F-loat May 11, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@steinslin steinslin self-assigned this May 15, 2018
@aOrz aOrz merged commit 6a9f6fe into mpvue:develop May 17, 2018
BugKun pushed a commit to BugKun/mpvue-loader that referenced this pull request Jun 1, 2020
修复相对路径资源无法正常引入的bug
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

Successfully merging this pull request may close these issues.

4 participants