-
Notifications
You must be signed in to change notification settings - Fork 51
修复相对路径资源无法正常引入的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
Conversation
if (firstChar === '.') { | ||
// 资源路径 | ||
var assetPath = path.resolve(path.dirname(fileOptions.resourcePath), value) | ||
// 小于limit的资源转base64 |
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.
对啦,在小程序里没有必要转 base64 啊。。。一整个就一个离线包,base64 反而可能影响解析速度
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.
主要是背景图还有字体啥的本地只能用 base64 格式的
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.
好像是没什么必要,背景图那些这里不会处理到,可以把limit默认设置为0吧
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.
所以背景图和字体还是不会被转换吗?有这个需求的人好像还挺多
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.
在css中引入的背景图是url-loader处理的,如果只有base64支持,可以把url-loader的配置limit调大
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.
背景图我记得好像没问题,字体没试过,理论上应该也可以,不知道为什么之前好多人说这个问题。。
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.
这里主要是处理 img 标签这类引用相对资源的话,确实不是很有必要转 base64
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.
修复相对路径资源无法正常引入的bug
@aOrz 那个bug没有重现,转base64后应该是没有再copy的,可能是之前留下的,可以先把dist remove掉再试试看有没被copy。另外存在一个bug,在windows下路径解析错误,这里修复了。