Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
菜鸟程序猿_c
uni-app
提交
27bc27d7
U
uni-app
项目概览
菜鸟程序猿_c
/
uni-app
与 Fork 源项目一致
Fork自
DCloud / uni-app
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
uni-app
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
27bc27d7
编写于
5月 11, 2020
作者:
fxy060608
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor(v3): asset url
上级
11ceb637
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
51 addition
and
24 deletion
+51
-24
packages/uni-cli-shared/lib/url-loader.js
packages/uni-cli-shared/lib/url-loader.js
+0
-6
packages/uni-template-compiler/lib/asset-url.js
packages/uni-template-compiler/lib/asset-url.js
+7
-13
packages/vue-cli-plugin-uni/index.js
packages/vue-cli-plugin-uni/index.js
+7
-2
packages/vue-cli-plugin-uni/lib/app-plus/getUrl.js
packages/vue-cli-plugin-uni/lib/app-plus/getUrl.js
+33
-0
packages/vue-cli-plugin-uni/lib/env.js
packages/vue-cli-plugin-uni/lib/env.js
+4
-3
未找到文件。
packages/uni-cli-shared/lib/url-loader.js
浏览文件 @
27bc27d7
...
@@ -10,12 +10,6 @@ const defaultOptions = {
...
@@ -10,12 +10,6 @@ const defaultOptions = {
loader
:
'
file-loader
'
,
loader
:
'
file-loader
'
,
options
:
{
options
:
{
publicPath
(
url
,
resourcePath
,
context
)
{
publicPath
(
url
,
resourcePath
,
context
)
{
if
(
process
.
env
.
UNI_PLATFORM
===
'
app-plus
'
&&
process
.
env
.
UNI_USING_V3
)
{
// app-plus v3 下路径不能以/开头
return
normalizePath
(
path
.
relative
(
process
.
env
.
UNI_INPUT_DIR
,
resourcePath
))
}
return
'
/
'
+
normalizePath
(
path
.
relative
(
process
.
env
.
UNI_INPUT_DIR
,
resourcePath
))
return
'
/
'
+
normalizePath
(
path
.
relative
(
process
.
env
.
UNI_INPUT_DIR
,
resourcePath
))
},
},
outputPath
(
url
,
resourcePath
,
context
)
{
outputPath
(
url
,
resourcePath
,
context
)
{
...
...
packages/uni-template-compiler/lib/asset-url.js
浏览文件 @
27bc27d7
...
@@ -43,14 +43,14 @@ function urlToRequire (url) {
...
@@ -43,14 +43,14 @@ function urlToRequire (url) {
* @param urlString an url as a string
* @param urlString an url as a string
*/
*/
function
parseUriParts
(
urlString
)
{
function
parseUriParts
(
urlString
)
{
// initialize return value
// initialize return value
/* eslint-disable node/no-deprecated-api */
/* eslint-disable node/no-deprecated-api */
const
returnValue
=
url
.
parse
(
''
)
const
returnValue
=
url
.
parse
(
''
)
if
(
urlString
)
{
if
(
urlString
)
{
// A TypeError is thrown if urlString is not a string
// A TypeError is thrown if urlString is not a string
// @see https://nodejs.org/api/url.html#url_url_parse_urlstring_parsequerystring_slashesdenotehost
// @see https://nodejs.org/api/url.html#url_url_parse_urlstring_parsequerystring_slashesdenotehost
if
(
typeof
urlString
===
'
string
'
)
{
if
(
typeof
urlString
===
'
string
'
)
{
// check is an uri
// check is an uri
/* eslint-disable node/no-deprecated-api */
/* eslint-disable node/no-deprecated-api */
return
url
.
parse
(
urlString
)
// take apart the uri
return
url
.
parse
(
urlString
)
// take apart the uri
}
}
...
@@ -68,18 +68,12 @@ function rewrite (attr, name, options) {
...
@@ -68,18 +68,12 @@ function rewrite (attr, name, options) {
.
replace
(
'
"@/
'
,
'
"/
'
)
.
replace
(
'
"@/
'
,
'
"/
'
)
.
replace
(
'
"~@/
'
,
'
"/
'
)
.
replace
(
'
"~@/
'
,
'
"/
'
)
}
}
// v3,h5
// h5
const
needRequire
=
options
.
service
||
options
.
view
||
options
.
h5
if
(
options
.
h5
)
{
if
(
needRequire
)
{
attr
.
value
=
urlToRequire
(
attr
.
value
.
slice
(
1
,
-
1
))
attr
.
value
=
urlToRequire
(
attr
.
value
.
slice
(
1
,
-
1
))
if
(
attr
.
value
.
startsWith
(
'
require("
'
))
{
// require
if
(
attr
.
value
.
startsWith
(
'
require("
'
)
&&
options
.
publicPath
===
'
./
'
)
{
// require
// v3 需要增加前缀 /
// h5 且 publicPath 为 ./ (仅生产模式可能为./)
if
(
options
.
service
||
options
.
view
)
{
attr
.
value
=
`(
${
attr
.
value
}
).substr(1)`
attr
.
value
=
`"/"+
${
attr
.
value
}
`
}
else
if
(
options
.
h5
&&
options
.
publicPath
===
'
./
'
)
{
// h5 且 publicPath 为 ./ (仅生产模式可能为./)
attr
.
value
=
`(
${
attr
.
value
}
).substr(1)`
}
}
}
}
}
return
true
return
true
...
...
packages/vue-cli-plugin-uni/index.js
浏览文件 @
27bc27d7
...
@@ -53,8 +53,13 @@ module.exports = (api, options) => {
...
@@ -53,8 +53,13 @@ module.exports = (api, options) => {
vueConfig
=
vueConfig
(
options
,
api
)
vueConfig
=
vueConfig
(
options
,
api
)
}
}
if
(
options
.
pages
)
{
// 允许 vue.config.js pages 覆盖
if
(
options
.
pages
)
{
delete
vueConfig
.
pages
// h5平台 允许 vue.config.js pages 覆盖,其他平台移除 pages 配置
if
(
process
.
env
.
UNI_PLATFORM
===
'
h5
'
)
{
delete
vueConfig
.
pages
}
else
{
delete
options
.
pages
}
}
}
Object
.
assign
(
options
,
{
// TODO 考虑非 HBuilderX 运行时,可以支持自定义输出目录
Object
.
assign
(
options
,
{
// TODO 考虑非 HBuilderX 运行时,可以支持自定义输出目录
...
...
packages/vue-cli-plugin-uni/lib/app-plus/getUrl.js
0 → 100644
浏览文件 @
27bc27d7
'
use strict
'
module
.
exports
=
function
(
url
,
options
)
{
if
(
!
options
)
{
// eslint-disable-next-line no-param-reassign
options
=
{}
}
// eslint-disable-next-line no-underscore-dangle, no-param-reassign
url
=
url
&&
url
.
__esModule
?
url
.
default
:
url
if
(
typeof
url
!==
'
string
'
)
{
return
url
}
// If url is already wrapped in quotes, remove them
if
(
/^
[
'"
]
.*
[
'"
]
$/
.
test
(
url
))
{
// eslint-disable-next-line no-param-reassign
url
=
url
.
slice
(
1
,
-
1
)
}
if
(
options
.
hash
)
{
// eslint-disable-next-line no-param-reassign
url
+=
options
.
hash
}
// Should url be wrapped?
// See https://drafts.csswg.org/css-values-3/#urls
if
(
/
[
"'()
\t\n]
/
.
test
(
url
)
||
options
.
needQuotes
)
{
return
'
"
'
.
concat
(
url
.
replace
(
/"/g
,
'
\\
"
'
).
replace
(
/
\n
/g
,
'
\\
n
'
),
'
"
'
)
}
if
(
url
.
indexOf
(
'
/
'
)
===
0
)
{
return
url
.
substr
(
1
)
}
return
url
}
packages/vue-cli-plugin-uni/lib/env.js
浏览文件 @
27bc27d7
...
@@ -2,8 +2,8 @@ const fs = require('fs')
...
@@ -2,8 +2,8 @@ const fs = require('fs')
const
path
=
require
(
'
path
'
)
const
path
=
require
(
'
path
'
)
const
mkdirp
=
require
(
'
mkdirp
'
)
const
mkdirp
=
require
(
'
mkdirp
'
)
const
loaderUtils
=
require
(
'
loader-utils
'
)
const
loaderUtils
=
require
(
'
loader-utils
'
)
require
(
'
./error-reporting
'
)
require
(
'
./error-reporting
'
)
const
hasOwnProperty
=
Object
.
prototype
.
hasOwnProperty
const
hasOwnProperty
=
Object
.
prototype
.
hasOwnProperty
...
@@ -335,7 +335,8 @@ moduleAlias.addAlias('mpvue-template-compiler', '@dcloudio/vue-cli-plugin-uni/pa
...
@@ -335,7 +335,8 @@ moduleAlias.addAlias('mpvue-template-compiler', '@dcloudio/vue-cli-plugin-uni/pa
// vue-loader
// vue-loader
moduleAlias
.
addAlias
(
'
vue-loader
'
,
'
@dcloudio/vue-cli-plugin-uni/packages/vue-loader
'
)
moduleAlias
.
addAlias
(
'
vue-loader
'
,
'
@dcloudio/vue-cli-plugin-uni/packages/vue-loader
'
)
if
(
process
.
env
.
UNI_USING_V3
&&
process
.
env
.
UNI_PLATFORM
===
'
app-plus
'
)
{
if
(
process
.
env
.
UNI_USING_V3
&&
process
.
env
.
UNI_PLATFORM
===
'
app-plus
'
)
{
moduleAlias
.
addAlias
(
'
../runtime/getUrl.js
'
,
'
@dcloudio/vue-cli-plugin-uni/lib/app-plus/getUrl.js
'
)
moduleAlias
.
addAlias
(
'
vue-style-loader
'
,
'
@dcloudio/vue-cli-plugin-uni/packages/app-vue-style-loader
'
)
moduleAlias
.
addAlias
(
'
vue-style-loader
'
,
'
@dcloudio/vue-cli-plugin-uni/packages/app-vue-style-loader
'
)
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录