Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
uni-app
提交
90275821
U
uni-app
项目概览
DCloud
/
uni-app
2 个月 前同步成功
通知
717
Star
38705
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
90275821
编写于
1月 08, 2020
作者:
fxy060608
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor(easycom): add autoscan option
上级
62bd1f92
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
35 addition
and
16 deletion
+35
-16
packages/uni-cli-shared/lib/pages.js
packages/uni-cli-shared/lib/pages.js
+22
-9
packages/vue-cli-plugin-uni/lib/env.js
packages/vue-cli-plugin-uni/lib/env.js
+8
-5
packages/vue-cli-plugin-uni/packages/webpack-uni-app-loader/plugin/index.js
...lugin-uni/packages/webpack-uni-app-loader/plugin/index.js
+3
-1
packages/webpack-uni-pages-loader/lib/index-new.js
packages/webpack-uni-pages-loader/lib/index-new.js
+2
-1
未找到文件。
packages/uni-cli-shared/lib/pages.js
浏览文件 @
90275821
...
...
@@ -334,7 +334,7 @@ let uniAutoImportComponents = []
let
uniAutoImportScanComponents
=
[]
function
initAutoImportScanComponents
()
{
function
initAutoImportScanComponents
()
{
const
componentsPath
=
path
.
resolve
(
process
.
env
.
UNI_INPUT_DIR
,
'
components
'
)
const
components
=
{}
try
{
...
...
@@ -347,12 +347,22 @@ function initAutoImportScanComponents () {
})
}
catch
(
e
)
{}
uniAutoImportScanComponents
=
parseUsingAutoImportComponents
(
components
)
uniAutoImportScanComponents
=
parseUsingAutoImportComponents
(
components
)
refreshAutoComponentMap
()
}
function
initAutoImportComponents
(
usingAutoImportComponents
=
{})
{
const
_toString
=
Object
.
prototype
.
toString
function
isPlainObject
(
obj
)
{
return
_toString
.
call
(
obj
)
===
'
[object Object]
'
}
function
initAutoImportComponents
(
easycom
=
{})
{
let
usingAutoImportComponents
=
easycom
.
custom
||
easycom
||
{}
if
(
!
isPlainObject
(
usingAutoImportComponents
))
{
usingAutoImportComponents
=
{}
}
// 目前仅 mp-weixin 内置支持 page-meta 等组件
if
(
process
.
env
.
UNI_PLATFORM
!==
'
mp-weixin
'
)
{
if
(
!
usingAutoImportComponents
[
'
^page-meta$
'
])
{
...
...
@@ -415,10 +425,13 @@ function parseUsingAutoImportComponents (usingAutoImportComponents) {
const
autoImportComponents
=
[]
if
(
usingAutoImportComponents
)
{
Object
.
keys
(
usingAutoImportComponents
).
forEach
(
pattern
=>
{
autoImportComponents
.
push
({
pattern
:
new
RegExp
(
pattern
),
replacement
:
usingAutoImportComponents
[
pattern
]
})
const
replacement
=
usingAutoImportComponents
[
pattern
]
if
(
replacement
&&
typeof
replacement
===
'
string
'
)
{
autoImportComponents
.
push
({
pattern
:
new
RegExp
(
pattern
),
replacement
:
replacement
})
}
})
}
return
autoImportComponents
...
...
@@ -432,7 +445,7 @@ module.exports = {
parsePagesJson
,
pagesJsonJsFileName
,
getAutoComponents
,
initAutoImportComponents
,
initAutoImportComponents
,
initAutoImportScanComponents
,
addPageUsingComponents
,
getUsingComponentsCode
,
...
...
packages/vue-cli-plugin-uni/lib/env.js
浏览文件 @
90275821
...
...
@@ -312,12 +312,15 @@ if (
}
const
{
initAutoImportComponents
,
initAutoImportComponents
,
initAutoImportScanComponents
}
=
require
(
'
@dcloudio/uni-cli-shared/lib/pages
'
)
initAutoImportScanComponents
()
initAutoImportComponents
(
pagesJsonObj
.
easycom
)
}
=
require
(
'
@dcloudio/uni-cli-shared/lib/pages
'
)
process
.
UNI_AUTO_SCAN_COMPONENTS
=
!
(
pagesJsonObj
.
easycom
&&
pagesJsonObj
.
easycom
.
autoscan
===
false
)
initAutoImportComponents
(
pagesJsonObj
.
easycom
)
if
(
process
.
UNI_AUTO_SCAN_COMPONENTS
)
{
initAutoImportScanComponents
()
}
runByHBuilderX
&&
console
.
log
(
`正在编译中...`
)
...
...
packages/vue-cli-plugin-uni/packages/webpack-uni-app-loader/plugin/index.js
浏览文件 @
90275821
...
...
@@ -13,7 +13,9 @@ class WebpackUniAppPlugin {
compiler
.
hooks
.
invalid
.
tap
(
'
webpack-uni-app-invalid
'
,
(
fileName
,
changeTime
)
=>
{
if
(
fileName
&&
typeof
fileName
===
'
string
'
)
{
if
(
fileName
.
indexOf
(
'
.vue
'
)
!==
-
1
||
fileName
.
indexOf
(
'
.nvue
'
)
!==
-
1
)
{
initAutoImportScanComponents
()
if
(
process
.
UNI_AUTO_SCAN_COMPONENTS
)
{
initAutoImportScanComponents
()
}
}
}
})
...
...
packages/webpack-uni-pages-loader/lib/index-new.js
浏览文件 @
90275821
...
...
@@ -56,6 +56,7 @@ module.exports = function (content) {
})
// 组件自动导入配置
process
.
UNI_AUTO_SCAN_COMPONENTS
=
!
(
pagesJson
.
easycom
&&
pagesJson
.
easycom
.
autoscan
===
false
)
initAutoImportComponents
(
pagesJson
.
easycom
)
// TODO 与 usingComponents 放在一块读取设置
...
...
@@ -128,4 +129,4 @@ module.exports = function (content) {
}
return
''
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录