Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
genary
uni-app
提交
9ef4b17b
U
uni-app
项目概览
genary
/
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,发现更多精彩内容 >>
提交
9ef4b17b
编写于
12月 20, 2019
作者:
fxy060608
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat(cli): refresh auto components when pages.json changed
上级
6e9848f5
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
44 addition
and
16 deletion
+44
-16
packages/uni-cli-shared/lib/pages.js
packages/uni-cli-shared/lib/pages.js
+24
-1
packages/vue-cli-plugin-uni/lib/env.js
packages/vue-cli-plugin-uni/lib/env.js
+0
-12
packages/webpack-uni-pages-loader/lib/index-new.js
packages/webpack-uni-pages-loader/lib/index-new.js
+20
-3
未找到文件。
packages/uni-cli-shared/lib/pages.js
浏览文件 @
9ef4b17b
...
...
@@ -328,6 +328,15 @@ function addPageUsingComponents (pagePath, usingComponents) {
// 存储自动组件
const
autoComponentMap
=
{}
/**
* UNI_AUTO_COMPONENTS 被更新,重新刷新 map
*/
function
refreshAutoComponentMap
()
{
Object
.
keys
(
autoComponentMap
).
forEach
(
name
=>
{
addAutoComponent
(
name
)
})
}
function
addAutoComponent
(
name
)
{
const
options
=
process
.
UNI_AUTO_COMPONENTS
const
opt
=
options
.
find
(
opt
=>
opt
.
pattern
.
test
(
name
))
...
...
@@ -355,6 +364,18 @@ function getAutoComponents (autoComponents) {
return
components
}
function
parseUsingAutoImportComponents
(
usingAutoImportComponents
)
{
const
autoImportComponents
=
[]
if
(
usingAutoImportComponents
)
{
Object
.
keys
(
usingAutoImportComponents
).
forEach
(
pattern
=>
{
autoImportComponents
.
push
({
pattern
:
new
RegExp
(
pattern
),
replacement
:
usingAutoImportComponents
[
pattern
]
})
})
}
return
autoImportComponents
}
module
.
exports
=
{
getMainEntry
,
getNVueMainEntry
,
...
...
@@ -363,10 +384,12 @@ module.exports = {
getPagesJson
,
parsePagesJson
,
pagesJsonJsFileName
,
getAutoComponents
,
getAutoComponents
,
refreshAutoComponentMap
,
addPageUsingComponents
,
getUsingComponentsCode
,
generateUsingComponentsCode
,
getGlobalUsingComponentsCode
,
parseUsingAutoImportComponents
,
generateGlobalUsingComponentsCode
}
packages/vue-cli-plugin-uni/lib/env.js
浏览文件 @
9ef4b17b
...
...
@@ -290,18 +290,6 @@ if (runByHBuilderX) {
}
}
}
// 组件自动导入配置
process
.
UNI_AUTO_COMPONENTS
=
[]
const
usingAutoImportComponents
=
pagesJsonObj
.
usingAutoImportComponents
if
(
usingAutoImportComponents
)
{
Object
.
keys
(
usingAutoImportComponents
).
forEach
(
pattern
=>
{
process
.
UNI_AUTO_COMPONENTS
.
push
({
pattern
:
new
RegExp
(
pattern
),
replacement
:
usingAutoImportComponents
[
pattern
]
})
})
}
if
(
process
.
env
.
UNI_USING_CACHE
&&
...
...
packages/webpack-uni-pages-loader/lib/index-new.js
浏览文件 @
9ef4b17b
...
...
@@ -17,7 +17,9 @@ const {
}
=
require
(
'
@dcloudio/uni-cli-shared/lib/cache
'
)
const
{
pagesJsonJsFileName
pagesJsonJsFileName
,
refreshAutoComponentMap
,
parseUsingAutoImportComponents
}
=
require
(
'
@dcloudio/uni-cli-shared/lib/pages
'
)
const
parseStyle
=
require
(
'
./util
'
).
parseStyle
...
...
@@ -31,6 +33,17 @@ function renameUsingComponents (jsonObj) {
return
jsonObj
}
let
lastUsingAutoImportComponentsJson
=
''
function
initAutoImportComponents
(
usingAutoImportComponents
=
{})
{
const
newUsingAutoImportComponentsJson
=
JSON
.
stringify
(
usingAutoImportComponents
)
if
(
newUsingAutoImportComponentsJson
!==
lastUsingAutoImportComponentsJson
)
{
lastUsingAutoImportComponentsJson
=
newUsingAutoImportComponentsJson
process
.
UNI_AUTO_COMPONENTS
=
parseUsingAutoImportComponents
(
usingAutoImportComponents
)
refreshAutoComponentMap
()
}
}
module
.
exports
=
function
(
content
)
{
this
.
cacheable
&&
this
.
cacheable
()
...
...
@@ -53,6 +66,10 @@ module.exports = function (content) {
this
.
addDependency
(
file
)
}
})
// 组件自动导入配置
initAutoImportComponents
(
pagesJson
.
usingAutoImportComponents
)
// TODO 与 usingComponents 放在一块读取设置
if
(
manifestJson
.
transformPx
===
false
)
{
process
.
UNI_TRANSFORM_PX
=
false
...
...
@@ -83,8 +100,8 @@ module.exports = function (content) {
if
(
jsonFile
)
{
if
(
jsonFile
.
name
===
'
define-pages.js
'
)
{
appConfigContent
=
jsonFile
.
content
}
else
{
// app-view 不需要生成 app-config-service.js,manifest.json
}
else
{
// app-view 不需要生成 app-config-service.js,manifest.json
!
isAppView
&&
this
.
emitFile
(
jsonFile
.
name
,
jsonFile
.
content
)
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录