Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Velpro187
uni-app
提交
9cabb543
U
uni-app
项目概览
Velpro187
/
uni-app
与 Fork 源项目一致
Fork自
DCloud / uni-app
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
uni-app
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
9cabb543
编写于
8月 16, 2021
作者:
fxy060608
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat(app): copy only changed files
上级
34a106c7
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
67 addition
and
8 deletion
+67
-8
packages/uni-app-vite/src/index.ts
packages/uni-app-vite/src/index.ts
+2
-0
packages/uni-app-vite/src/plugins/stats.ts
packages/uni-app-vite/src/plugins/stats.ts
+40
-0
packages/uni-cli-nvue/src/webpack/plugin/WatchPlugin.ts
packages/uni-cli-nvue/src/webpack/plugin/WatchPlugin.ts
+4
-4
packages/vite-plugin-uni/src/cli/action.ts
packages/vite-plugin-uni/src/cli/action.ts
+21
-4
未找到文件。
packages/uni-app-vite/src/index.ts
浏览文件 @
9cabb543
...
...
@@ -12,6 +12,7 @@ import { uniManifestJsonPlugin } from './plugins/manifestJson'
import
{
uniPagesJsonPlugin
}
from
'
./plugins/pagesJson
'
// import { uniResolveIdPlugin } from './plugins/resolveId'
import
{
uniRenderjsPlugin
}
from
'
./plugins/renderjs
'
import
{
uniStatsPlugin
}
from
'
./plugins/stats
'
function
initUniCssScopedPluginOptions
()
{
const
styleIsolation
=
getAppStyleIsolation
(
...
...
@@ -36,6 +37,7 @@ const plugins = [
uniViteInjectPlugin
(
initProvide
()),
uniRenderjsPlugin
(),
uniTemplatePlugin
(),
uniStatsPlugin
(),
UniAppPlugin
,
]
...
...
packages/uni-app-vite/src/plugins/stats.ts
0 → 100644
浏览文件 @
9cabb543
import
{
Plugin
,
ResolvedConfig
}
from
'
vite
'
import
{
hash
}
from
'
@dcloudio/uni-cli-shared
'
const
emittedHashMap
=
new
WeakMap
<
ResolvedConfig
,
Map
<
string
,
string
>>
()
export
function
uniStatsPlugin
():
Plugin
{
let
resolvedConfig
:
ResolvedConfig
return
{
name
:
'
vite:uni-app-stats
'
,
enforce
:
'
post
'
,
configResolved
(
config
)
{
resolvedConfig
=
config
emittedHashMap
.
set
(
resolvedConfig
,
new
Map
<
string
,
string
>
())
},
writeBundle
(
_
,
bundle
)
{
if
(
resolvedConfig
.
isProduction
)
{
// 仅dev生效
return
}
const
emittedHash
=
emittedHashMap
.
get
(
resolvedConfig
)
!
const
changedFiles
:
string
[]
=
[]
Object
.
keys
(
bundle
).
forEach
((
filename
)
=>
{
const
outputFile
=
bundle
[
filename
]
let
outputFileHash
=
''
if
(
outputFile
.
type
===
'
asset
'
)
{
outputFileHash
=
hash
(
outputFile
.
source
)
}
else
{
outputFileHash
=
hash
(
outputFile
.
code
)
}
if
(
emittedHash
.
get
(
filename
)
!==
outputFileHash
)
{
emittedHash
.
set
(
filename
,
outputFileHash
)
changedFiles
.
push
(
filename
)
}
})
process
.
env
.
UNI_APP_CHANGED_FILES
=
changedFiles
.
length
?
JSON
.
stringify
(
changedFiles
)
:
''
},
}
}
packages/uni-cli-nvue/src/webpack/plugin/WatchPlugin.ts
浏览文件 @
9cabb543
...
...
@@ -23,9 +23,6 @@ export default class WatchPlugin {
})
compiler
.
hooks
.
done
.
tap
(
'
WatchPlugin
'
,
(
stats
)
=>
{
isCompiling
=
false
if
(
isFirst
)
{
return
(
isFirst
=
false
)
}
const
changedFiles
:
Set
<
string
>
=
new
Set
<
string
>
()
stats
.
compilation
.
chunks
.
forEach
(({
name
,
hash
,
files
})
=>
{
if
(
!
hash
)
{
...
...
@@ -38,7 +35,7 @@ export default class WatchPlugin {
}
files
.
forEach
((
file
)
=>
changedFiles
.
add
(
file
))
})
if
(
changedFiles
.
size
)
{
if
(
!
isFirst
&&
changedFiles
.
size
)
{
console
.
log
(
M
[
'
dev.watching.end.pages
'
].
replace
(
'
{pages}
'
,
...
...
@@ -46,6 +43,9 @@ export default class WatchPlugin {
)
)
}
else
{
if
(
isFirst
)
{
return
(
isFirst
=
false
)
}
console
.
log
(
M
[
'
dev.watching.end
'
])
}
})
...
...
packages/vite-plugin-uni/src/cli/action.ts
浏览文件 @
9cabb543
...
...
@@ -15,16 +15,33 @@ export async function runDev(options: CliOptions & ServerOptions) {
await
(
options
.
ssr
?
createSSRServer
(
options
)
:
createServer
(
options
))
}
else
{
const
watcher
=
(
await
build
(
options
))
as
RollupWatcher
let
isFirst
=
true
let
isFirstStart
=
true
let
isFirstEnd
=
true
watcher
.
on
(
'
event
'
,
(
event
)
=>
{
if
(
event
.
code
===
'
BUNDLE_START
'
)
{
if
(
isFirst
)
{
return
(
isFirst
=
false
)
if
(
isFirst
Start
)
{
return
(
isFirst
Start
=
false
)
}
console
.
log
(
M
[
'
dev.watching.start
'
])
}
else
if
(
event
.
code
===
'
BUNDLE_END
'
)
{
event
.
result
.
close
()
console
.
log
(
M
[
'
dev.watching.end
'
])
if
(
options
.
platform
!==
'
app
'
)
{
// 非App平台无需处理增量同步
return
console
.
log
(
M
[
'
dev.watching.end
'
])
}
if
(
isFirstEnd
)
{
// 首次全量同步
return
(
isFirstEnd
=
false
),
console
.
log
(
M
[
'
dev.watching.end
'
])
}
if
(
process
.
env
.
UNI_APP_CHANGED_FILES
)
{
return
console
.
log
(
M
[
'
dev.watching.end.files
'
].
replace
(
'
{files}
'
,
process
.
env
.
UNI_APP_CHANGED_FILES
)
)
}
return
console
.
log
(
M
[
'
dev.watching.end
'
])
}
})
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录