Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
uni-app
提交
c276f6c6
U
uni-app
项目概览
DCloud
/
uni-app
4 个月 前同步成功
通知
730
Star
38706
Fork
3642
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
7
列表
看板
标记
里程碑
合并请求
1
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
uni-app
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
7
Issue
7
列表
看板
标记
里程碑
合并请求
1
合并请求
1
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
c276f6c6
编写于
11月 13, 2020
作者:
fxy060608
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix(cli): uni_modules with easycom
上级
6ae16fb3
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
32 addition
and
19 deletion
+32
-19
packages/uni-cli-shared/lib/pages.js
packages/uni-cli-shared/lib/pages.js
+23
-16
packages/webpack-uni-pages-loader/lib/platforms/mp.js
packages/webpack-uni-pages-loader/lib/platforms/mp.js
+9
-3
未找到文件。
packages/uni-cli-shared/lib/pages.js
浏览文件 @
c276f6c6
...
...
@@ -339,20 +339,27 @@ const isDirectory = source => fs.lstatSync(source).isDirectory()
function
getAutoComponentsByDir
(
componentsPath
,
absolute
=
false
)
{
const
components
=
{}
try
{
fs
.
existsSync
(
componentsPath
)
&&
fs
.
readdirSync
(
componentsPath
).
forEach
(
name
=>
{
const
folder
=
path
.
resolve
(
componentsPath
,
name
)
if
(
!
isDirectory
(
folder
))
{
return
if
(
fs
.
existsSync
(
componentsPath
))
{
let
importComponentsDir
=
'
@/components
'
const
uniModulesDir
=
path
.
resolve
(
process
.
env
.
UNI_INPUT_DIR
,
'
uni_modules
'
)
if
(
!
absolute
&&
componentsPath
.
includes
(
uniModulesDir
))
{
importComponentsDir
=
`@/uni_modules/
${
path
.
basename
(
path
.
dirname
(
componentsPath
))}
/components`
}
const
importDir
=
absolute
?
normalizePath
(
folder
)
:
`@/components/
${
name
}
`
// 读取文件夹文件列表,比对文件名(fs.existsSync在大小写不敏感的系统会匹配不准确)
const
files
=
fs
.
readdirSync
(
folder
)
if
(
files
.
includes
(
name
+
'
.vue
'
))
{
components
[
`^
${
name
}
$`
]
=
`
${
importDir
}
/
${
name
}
.vue`
}
else
if
(
files
.
includes
(
name
+
'
.nvue
'
))
{
components
[
`^
${
name
}
$`
]
=
`
${
importDir
}
/
${
name
}
.nvue`
}
})
fs
.
readdirSync
(
componentsPath
).
forEach
(
name
=>
{
const
folder
=
path
.
resolve
(
componentsPath
,
name
)
if
(
!
isDirectory
(
folder
))
{
return
}
const
importDir
=
absolute
?
normalizePath
(
folder
)
:
`
${
importComponentsDir
}
/
${
name
}
`
// 读取文件夹文件列表,比对文件名(fs.existsSync在大小写不敏感的系统会匹配不准确)
const
files
=
fs
.
readdirSync
(
folder
)
if
(
files
.
includes
(
name
+
'
.vue
'
))
{
components
[
`^
${
name
}
$`
]
=
`
${
importDir
}
/
${
name
}
.vue`
}
else
if
(
files
.
includes
(
name
+
'
.nvue
'
))
{
components
[
`^
${
name
}
$`
]
=
`
${
importDir
}
/
${
name
}
.nvue`
}
})
}
}
catch
(
e
)
{
console
.
log
(
e
)
}
...
...
@@ -365,8 +372,9 @@ function initAutoComponents () {
global
.
uniModules
.
forEach
(
module
=>
{
componentsDirs
.
push
(
path
.
resolve
(
process
.
env
.
UNI_INPUT_DIR
,
'
uni_modules
'
,
module
,
'
components
'
))
})
componentsDirs
.
forEach
(
componentsDir
=>
{
const
currentComponents
=
getAutoComponentsByDir
(
componentsDir
,
true
)
componentsDirs
.
forEach
((
componentsDir
)
=>
{
// 根目录 components 使用相对路径,uni_modules 使用绝对路径
const
currentComponents
=
getAutoComponentsByDir
(
componentsDir
,
false
)
Object
.
keys
(
currentComponents
).
forEach
(
name
=>
{
(
allComponents
[
name
]
||
(
allComponents
[
name
]
=
[])).
push
(
currentComponents
[
name
])
})
...
...
@@ -384,7 +392,6 @@ function initAutoComponents () {
conflictFiles
.
forEach
(
files
=>
{
let
usedFile
console
.
warn
(
'
easycom组件冲突:[
'
+
files
.
map
((
file
,
index
)
=>
{
file
=
path
.
relative
(
process
.
env
.
UNI_INPUT_DIR
,
file
)
if
(
index
===
0
)
{
usedFile
=
file
}
...
...
packages/webpack-uni-pages-loader/lib/platforms/mp.js
浏览文件 @
c276f6c6
...
...
@@ -171,6 +171,12 @@ function getCondition (pagesJson) {
}
return
false
}
function
trimAppJson
(
app
)
{
delete
app
.
topWindow
delete
app
.
leftWindow
delete
app
.
rightWindow
}
module
.
exports
=
function
(
pagesJson
,
manifestJson
,
project
=
{})
{
const
app
=
{
...
...
@@ -245,14 +251,14 @@ module.exports = function (pagesJson, manifestJson, project = {}) {
return
{
app
:
{
name
:
'
app
'
,
content
:
app
content
:
trimAppJson
(
app
)
}
}
}
return
{
app
:
{
name
:
'
app
'
,
content
:
app
content
:
trimAppJson
(
app
)
},
project
:
{
name
:
'
project.config
'
,
...
...
@@ -311,7 +317,7 @@ module.exports = function (pagesJson, manifestJson, project = {}) {
return
{
app
:
{
name
:
'
app
'
,
content
:
app
content
:
trimAppJson
(
app
)
},
project
:
{
name
:
'
project.config
'
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录