Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Velpro187
uni-app
提交
e4304403
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,发现更多精彩内容 >>
提交
e4304403
编写于
12月 30, 2021
作者:
fxy060608
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix: ignore non-current platform static (#3132)
上级
e7b75950
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
64 addition
and
6 deletion
+64
-6
packages/uni-cli-shared/src/index.ts
packages/uni-cli-shared/src/index.ts
+1
-0
packages/uni-cli-shared/src/platform.ts
packages/uni-cli-shared/src/platform.ts
+28
-0
packages/uni-cli-shared/src/vite/plugins/copy.ts
packages/uni-cli-shared/src/vite/plugins/copy.ts
+7
-2
packages/uni-cli-shared/src/watcher.ts
packages/uni-cli-shared/src/watcher.ts
+3
-3
packages/vite-plugin-uni/src/plugins/copy.ts
packages/vite-plugin-uni/src/plugins/copy.ts
+21
-0
packages/vite-plugin-uni/src/utils/plugin.ts
packages/vite-plugin-uni/src/utils/plugin.ts
+4
-1
未找到文件。
packages/uni-cli-shared/src/index.ts
浏览文件 @
e4304403
...
...
@@ -19,6 +19,7 @@ export * from './filter'
export
*
from
'
./esbuild
'
export
*
from
'
./resolve
'
export
*
from
'
./scripts
'
export
*
from
'
./platform
'
export
{
M
}
from
'
./messages
'
...
...
packages/uni-cli-shared/src/platform.ts
0 → 100644
浏览文件 @
e4304403
const
BUILT_IN_PLATFORMS
=
[
'
app
'
,
'
app-plus
'
,
'
h5
'
,
'
mp-360
'
,
'
mp-alipay
'
,
'
mp-baidu
'
,
'
mp-jd
'
,
'
mp-kuaishou
'
,
'
mp-lark
'
,
'
mp-qq
'
,
'
mp-toutiao
'
,
'
mp-weixin
'
,
'
quickapp-webview
'
,
'
quickapp-webview-huawei
'
,
'
quickapp-webview-union
'
,
]
const
platforms
=
[...
BUILT_IN_PLATFORMS
]
export
function
registerPlatform
(
platform
:
string
)
{
if
(
!
platforms
.
includes
(
platform
))
{
platforms
.
push
(
platform
)
}
}
export
function
getPlatforms
()
{
return
platforms
}
packages/uni-cli-shared/src/vite/plugins/copy.ts
浏览文件 @
e4304403
import
type
{
WatchOptions
}
from
'
chokidar
'
import
type
{
Plugin
,
ResolvedConfig
}
from
'
vite
'
import
{
FileWatcher
,
FileWatcherOptions
}
from
'
../../watcher
'
import
{
M
}
from
'
../../messages
'
export
type
UniViteCopyPluginTarget
=
Omit
<
FileWatcherOptions
,
'
verbose
'
>
export
type
UniViteCopyPluginTarget
=
Omit
<
FileWatcherOptions
,
'
verbose
'
>
&
{
watchOptions
?:
WatchOptions
}
export
interface
UniViteCopyPluginOptions
{
targets
:
UniViteCopyPluginTarget
[]
verbose
:
boolean
...
...
@@ -28,7 +32,7 @@ export function uniViteCopyPlugin({
inited
=
true
return
new
Promise
((
resolve
)
=>
{
Promise
.
all
(
targets
.
map
((
target
)
=>
{
targets
.
map
((
{
watchOptions
,
...
target
}
)
=>
{
return
new
Promise
((
resolve
)
=>
{
new
FileWatcher
({
verbose
,
...
...
@@ -36,6 +40,7 @@ export function uniViteCopyPlugin({
}).
watch
(
{
cwd
:
process
.
env
.
UNI_INPUT_DIR
,
...
watchOptions
,
},
(
watcher
)
=>
{
if
(
process
.
env
.
NODE_ENV
!==
'
development
'
)
{
...
...
packages/uni-cli-shared/src/watcher.ts
浏览文件 @
e4304403
...
...
@@ -68,14 +68,14 @@ export class FileWatcher {
if
(
content
)
{
return
fs
.
outputFile
(
to
,
content
)
.
catch
((
e
)
=>
{
.
catch
(()
=>
{
// this.info('copy', e)
})
.
then
(()
=>
this
.
onChange
&&
this
.
onChange
())
}
return
fs
.
copy
(
this
.
from
(
from
),
to
,
{
overwrite
:
true
})
.
catch
((
e
)
=>
{
.
catch
(()
=>
{
// this.info('copy', e)
})
.
then
(()
=>
this
.
onChange
&&
this
.
onChange
())
...
...
@@ -85,7 +85,7 @@ export class FileWatcher {
this
.
info
(
'
remove
'
,
from
+
'
=>
'
+
to
)
return
fs
.
remove
(
to
)
.
catch
((
e
)
=>
{
.
catch
(()
=>
{
// this.info('remove', e)
})
.
then
(()
=>
this
.
onChange
&&
this
.
onChange
())
...
...
packages/vite-plugin-uni/src/plugins/copy.ts
浏览文件 @
e4304403
import
fs
from
'
fs
'
import
path
from
'
path
'
import
debug
from
'
debug
'
import
type
{
Plugin
}
from
'
vite
'
...
...
@@ -8,6 +9,7 @@ import {
UniViteCopyPluginTarget
,
parseSubpackagesRootOnce
,
normalizePath
,
getPlatforms
,
}
from
'
@dcloudio/uni-cli-shared
'
import
{
VitePluginUniResolvedOptions
}
from
'
..
'
...
...
@@ -31,10 +33,29 @@ export function uniCopyPlugin({
copyOptions
!
.
assets
.
forEach
((
asset
)
=>
{
assets
.
push
(
asset
)
})
const
platform
=
process
.
env
.
UNI_PLATFORM
// 非当前平台 static 目录
const
platformStaticDirs
=
getPlatforms
()
.
filter
((
p
)
=>
{
if
(
platform
===
'
app
'
)
{
return
p
!==
'
app
'
&&
p
!==
'
app-plus
'
}
return
p
!==
platform
})
.
map
((
p
)
=>
'
/
'
+
PUBLIC_DIR
+
'
/
'
+
p
)
const
targets
:
UniViteCopyPluginTarget
[]
=
[
{
src
:
assets
,
dest
:
outputDir
,
watchOptions
:
{
ignored
(
path
:
string
)
{
const
normalizedPath
=
normalizePath
(
path
)
if
(
platformStaticDirs
.
find
((
dir
)
=>
normalizedPath
.
includes
(
dir
)))
{
return
fs
.
statSync
(
normalizedPath
).
isDirectory
}
},
},
},
]
targets
.
push
(...
copyOptions
!
.
targets
)
...
...
packages/vite-plugin-uni/src/utils/plugin.ts
浏览文件 @
e4304403
import
path
from
'
path
'
import
type
{
Plugin
}
from
'
vite
'
import
{
extend
,
isArray
,
isString
,
isFunction
}
from
'
@vue/shared
'
import
type
{
import
{
CopyOptions
,
registerPlatform
,
UniViteCopyPluginTarget
,
UniVitePlugin
,
}
from
'
@dcloudio/uni-cli-shared
'
...
...
@@ -116,6 +117,8 @@ function resolvePlugins(cliRoot: string, platform: UniApp.PLATFORM) {
}
const
{
apply
}
=
config
if
(
isArray
(
apply
))
{
// 注册所有平台
apply
.
forEach
((
p
)
=>
registerPlatform
(
p
))
if
(
!
apply
.
includes
(
platform
))
{
return
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录