提交 a4ee2536 编写于 作者: Q qiang

fix(h5): 相对路径编译模式资源转换改在运行时 question/96767

上级 61d82685
......@@ -72,14 +72,6 @@ function rewrite (attr, name, options) {
const needRequire = options.service || options.view || options.h5
if (needRequire) {
attr.value = urlToRequire(attr.value.slice(1, -1))
if (
options.h5 &&
options.publicPath === './' &&
attr.value.startsWith('require("')
) { // require
// h5 且 publicPath 为 ./ (仅生产模式可能为./)
attr.value = `(${attr.value}).replace(/^\\./,'')`
}
}
return true
}
......
......@@ -18,6 +18,10 @@ function addBase (filePath) {
}
export default function getRealPath (filePath) {
// 相对路径模式对静态资源路径特殊处理
if (__uniConfig.router.base === './') {
filePath = filePath.replace(/^\.\/static\//, '/static/')
}
if (filePath.indexOf('/') === 0) {
if (filePath.indexOf('//') === 0) {
filePath = 'https:' + filePath
......@@ -36,4 +40,4 @@ export default function getRealPath (filePath) {
}
return filePath
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册