Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
CoderSmallfan
uni-app
提交
4474c746
U
uni-app
项目概览
CoderSmallfan
/
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,发现更多精彩内容 >>
提交
4474c746
编写于
11月 10, 2020
作者:
fxy060608
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat(cli): add uni_modules.js
上级
829df827
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
63 addition
and
6 deletion
+63
-6
packages/uni-cli-shared/lib/pages.js
packages/uni-cli-shared/lib/pages.js
+4
-5
packages/uni-cli-shared/lib/uni_modules.js
packages/uni-cli-shared/lib/uni_modules.js
+51
-0
packages/webpack-uni-pages-loader/lib/index.js
packages/webpack-uni-pages-loader/lib/index.js
+8
-1
未找到文件。
packages/uni-cli-shared/lib/pages.js
浏览文件 @
4474c746
...
...
@@ -9,10 +9,13 @@ const {
}
=
require
(
'
./util
'
)
const
{
getJson
,
parseJson
}
=
require
(
'
./json
'
)
const
{
getPagesJson
}
=
require
(
'
./uni_modules
'
)
let
mainEntry
=
''
let
nvueMainEntry
=
''
...
...
@@ -33,10 +36,6 @@ function getNVueMainEntry () {
return
nvueMainEntry
}
function
getPagesJson
()
{
return
processPagesJson
(
getJson
(
'
pages.json
'
,
true
))
}
function
parsePagesJson
(
content
,
loader
)
{
return
processPagesJson
(
parseJson
(
content
,
true
),
loader
)
}
...
...
packages/
webpack-uni-pages-loader
/lib/uni_modules.js
→
packages/
uni-cli-shared
/lib/uni_modules.js
浏览文件 @
4474c746
...
...
@@ -3,8 +3,9 @@ const path = require('path')
const
{
parseJson
}
=
require
(
'
@dcloudio/uni-cli-shared/lib/json
'
)
const
merge
=
require
(
'
@dcloudio/uni-cli-shared/lib/pages-json
'
).
default
}
=
require
(
'
./json
'
)
const
merge
=
require
(
'
./pages-json
'
).
default
function
normalizeUniModulesPagesJson
(
pagesJson
,
pluginId
)
{
if
(
Array
.
isArray
(
pagesJson
.
pages
))
{
...
...
@@ -20,28 +21,31 @@ function normalizeUniModulesPagesJson (pagesJson, pluginId) {
return
pagesJson
}
module
.
exports
=
function
parsePages
(
content
)
{
const
uniModulesDir
=
path
.
resolve
(
process
.
env
.
UNI_INPUT_DIR
,
'
uni_modules
'
)
const
pluginPagesJsons
=
[]
global
.
uniModules
.
forEach
(
plugin
=>
{
const
pagesJsonPath
=
path
.
resolve
(
uniModulesDir
,
plugin
,
'
pages.json
'
)
if
(
fs
.
existsSync
(
pagesJsonPath
))
{
pluginPagesJsons
.
push
(
normalizeUniModulesPagesJson
(
parseJson
(
fs
.
readFileSync
(
pagesJsonPath
).
toString
(),
true
),
plugin
)
)
}
})
if
(
pluginPagesJsons
.
length
)
{
module
.
exports
=
{
getPagesJson
(
content
)
{
const
uniModulesDir
=
path
.
resolve
(
process
.
env
.
UNI_INPUT_DIR
,
'
uni_modules
'
)
const
pluginPagesJsons
=
[]
global
.
uniModules
.
forEach
(
plugin
=>
{
const
pagesJsonPath
=
path
.
resolve
(
uniModulesDir
,
plugin
,
'
pages.json
'
)
if
(
fs
.
existsSync
(
pagesJsonPath
))
{
pluginPagesJsons
.
push
(
normalizeUniModulesPagesJson
(
parseJson
(
fs
.
readFileSync
(
pagesJsonPath
).
toString
(),
true
),
plugin
)
)
}
})
content
=
content
||
fs
.
readFileSync
(
path
.
resolve
(
process
.
env
.
UNI_INPUT_DIR
,
'
pages.json
'
),
'
utf8
'
)
const
mainPagesJson
=
parseJson
(
content
,
true
)
const
pagesJson
=
merge
(
pluginPagesJsons
.
concat
(
mainPagesJson
))
if
(
Array
.
isArray
(
mainPagesJson
.
pages
))
{
// entry page
const
entryPagePath
=
mainPagesJson
.
pages
[
0
].
path
const
index
=
pagesJson
.
pages
.
findIndex
(
page
=>
page
.
path
===
entryPagePath
)
const
entryPage
=
pagesJson
.
pages
[
index
]
pagesJson
.
pages
.
splice
(
index
,
1
)
pagesJson
.
pages
.
unshift
(
entryPage
)
if
(
pluginPagesJsons
.
length
)
{
const
pagesJson
=
merge
(
pluginPagesJsons
.
concat
(
mainPagesJson
))
if
(
Array
.
isArray
(
mainPagesJson
.
pages
))
{
// entry page
const
entryPagePath
=
mainPagesJson
.
pages
[
0
].
path
const
index
=
pagesJson
.
pages
.
findIndex
(
page
=>
page
.
path
===
entryPagePath
)
const
entryPage
=
pagesJson
.
pages
[
index
]
pagesJson
.
pages
.
splice
(
index
,
1
)
pagesJson
.
pages
.
unshift
(
entryPage
)
}
return
pagesJson
}
return
JSON
.
stringify
(
pagesJson
)
return
mainPagesJson
}
return
content
}
packages/webpack-uni-pages-loader/lib/index.js
浏览文件 @
4474c746
...
...
@@ -30,7 +30,7 @@ function checkEmitFile (filePath, jsonObj, changedEmitFiles) {
}
module
.
exports
=
function
(
content
,
map
)
{
content
=
require
(
'
./uni_modules.js
'
)(
content
)
content
=
JSON
.
stringify
(
require
(
'
@dcloudio/uni-cli-shared/lib/uni_modules
'
).
getPagesJson
(
content
)
)
if
(
this
.
resourceQuery
)
{
const
params
=
loaderUtils
.
parseQuery
(
this
.
resourceQuery
)
if
(
params
)
{
...
...
@@ -41,6 +41,13 @@ module.exports = function (content, map) {
}
}
}
// add deps
global
.
uniModules
.
forEach
(
module
=>
{
const
uniModulePagesJsonPath
=
path
.
resolve
(
process
.
env
.
UNI_INPUT_DIR
,
'
uni_modules
'
,
module
,
'
pages.json
'
)
if
(
fs
.
existsSync
(
uniModulePagesJsonPath
))
{
this
.
addDependency
(
uniModulePagesJsonPath
)
}
})
if
(
process
.
env
.
UNI_USING_COMPONENTS
||
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录