Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
uni-app
提交
3c2123f7
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,发现更多精彩内容 >>
提交
3c2123f7
编写于
3月 30, 2021
作者:
fxy060608
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat(build): add copy plugin
上级
b6ccf252
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
100 addition
and
8 deletion
+100
-8
dist/static/logo.png
dist/static/logo.png
+0
-0
packages/vite-plugin-uni/package.json
packages/vite-plugin-uni/package.json
+1
-0
packages/vite-plugin-uni/src/config/index.ts
packages/vite-plugin-uni/src/config/index.ts
+0
-2
packages/vite-plugin-uni/src/configResolved/plugins/copy.ts
packages/vite-plugin-uni/src/configResolved/plugins/copy.ts
+28
-0
packages/vite-plugin-uni/src/configResolved/plugins/index.ts
packages/vite-plugin-uni/src/configResolved/plugins/index.ts
+4
-0
packages/vite-plugin-uni/src/index.ts
packages/vite-plugin-uni/src/index.ts
+12
-1
yarn.lock
yarn.lock
+55
-5
未找到文件。
dist/static/logo.png
0 → 100644
浏览文件 @
3c2123f7
3.9 KB
packages/vite-plugin-uni/package.json
浏览文件 @
3c2123f7
...
...
@@ -27,6 +27,7 @@
"fs-extra"
:
"^9.0.1"
,
"jsonc-parser"
:
"^3.0.0"
,
"magic-string"
:
"^0.25.7"
,
"rollup-plugin-copy"
:
"^3.4.0"
,
"slash"
:
"^3.0.0"
},
"peerDependencies"
:
{
...
...
packages/vite-plugin-uni/src/config/index.ts
浏览文件 @
3c2123f7
import
path
from
'
path
'
import
{
Plugin
}
from
'
vite
'
import
{
VitePluginUniResolvedOptions
}
from
'
..
'
...
...
@@ -25,7 +24,6 @@ export function createConfig(
server
:
createServer
(
options
),
build
:
createBuild
(
options
),
css
:
createCss
(
options
),
publicDir
:
path
.
join
(
options
.
inputDir
,
'
static
'
),
}
}
}
packages/vite-plugin-uni/src/configResolved/plugins/copy.ts
0 → 100644
浏览文件 @
3c2123f7
import
path
from
'
path
'
import
{
Plugin
}
from
'
vite
'
import
copy
from
'
rollup-plugin-copy
'
import
{
VitePluginUniResolvedOptions
}
from
'
../..
'
export
function
uniCopyPlugin
({
inputDir
,
outputDir
,
}:
VitePluginUniResolvedOptions
):
Plugin
{
// TODO 多平台,如 h5,app 的 hybrid/html 目录
return
copy
({
targets
:
[
{
src
:
path
.
resolve
(
inputDir
,
'
static
'
),
dest
:
outputDir
,
},
{
src
:
path
.
resolve
(
inputDir
,
'
uni_modules/*/static
'
),
dest
:
outputDir
,
rename
:
(
name
,
extension
,
fullPath
)
=>
{
return
path
.
relative
(
inputDir
,
fullPath
)
},
},
],
hook
:
'
writeBundle
'
,
verbose
:
process
.
env
.
DEBUG
?
true
:
false
,
})
}
packages/vite-plugin-uni/src/configResolved/plugins/index.ts
浏览文件 @
3c2123f7
...
...
@@ -13,6 +13,7 @@ import { uniMainJsPlugin } from './mainJs'
import
{
uniPagesJsonPlugin
}
from
'
./pagesJson
'
import
{
uniManifestJsonPlugin
}
from
'
./manifestJson
'
import
{
uniPageVuePlugin
}
from
'
./pageVue
'
import
{
uniCopyPlugin
}
from
'
./copy
'
const
debugPlugin
=
debug
(
'
uni:plugin
'
)
...
...
@@ -92,6 +93,9 @@ export function resolvePlugins(
)
addPlugin
(
plugins
,
uniPageVuePlugin
({
command
}),
'
vite:vue
'
)
addPlugin
(
plugins
,
uniJsonPlugin
(
options
),
'
vite:json
'
,
'
pre
'
)
if
(
command
===
'
build
'
)
{
addPlugin
(
plugins
,
uniCopyPlugin
(
options
),
plugins
.
length
)
}
if
(
process
.
env
.
DEBUG
)
{
debugPlugin
(
plugins
.
length
)
debugPlugin
(
plugins
.
map
((
p
)
=>
(
p
as
Plugin
).
name
))
...
...
packages/vite-plugin-uni/src/index.ts
浏览文件 @
3c2123f7
...
...
@@ -12,6 +12,7 @@ import { createConfigureServer } from './configureServer'
import
{
createHandleHotUpdate
}
from
'
./handleHotUpdate
'
export
interface
VitePluginUniOptions
{
inputDir
?:
string
outputDir
?:
string
}
export
interface
VitePluginUniResolvedOptions
extends
VitePluginUniOptions
{
root
:
string
...
...
@@ -19,6 +20,7 @@ export interface VitePluginUniResolvedOptions extends VitePluginUniOptions {
command
:
ResolvedConfig
[
'
command
'
]
platform
:
UniApp
.
PLATFORM
inputDir
:
string
outputDir
:
string
assetsDir
:
string
devServer
?:
ViteDevServer
}
...
...
@@ -35,13 +37,22 @@ function resolveBase(inputDir: string) {
export
default
function
uniPlugin
(
rawOptions
:
VitePluginUniOptions
=
{}
):
Plugin
{
const
inputDir
=
rawOptions
.
inputDir
||
path
.
resolve
(
process
.
cwd
(),
'
src
'
)
const
inputDir
=
process
.
env
.
UNI_INPUT_DIR
||
rawOptions
.
inputDir
||
path
.
resolve
(
process
.
cwd
(),
'
src
'
)
const
outputDir
=
process
.
env
.
UNI_OUTPUT_DIR
||
rawOptions
.
outputDir
||
path
.
resolve
(
process
.
cwd
(),
'
dist
'
)
const
options
:
VitePluginUniResolvedOptions
=
{
...
rawOptions
,
root
:
process
.
cwd
(),
base
:
resolveBase
(
inputDir
),
assetsDir
:
'
assets
'
,
inputDir
,
outputDir
,
command
:
'
serve
'
,
platform
:
'
h5
'
,
}
...
...
yarn.lock
浏览文件 @
3c2123f7
...
...
@@ -788,6 +788,13 @@
resolved "https://registry.yarnpkg.com/@types/estree/-/estree-0.0.39.tgz#e177e699ee1b8c22d23174caaa7422644389509f"
integrity sha512-EYNwp3bU+98cpU4lAWYYL7Zz+2gryWH1qbdDTidVd6hkiR6weksdbMadyXKXNPEkQFhXM+hVO9ZygomHXp+AIw==
"@types/fs-extra@^8.0.1":
version "8.1.1"
resolved "https://registry.yarnpkg.com/@types/fs-extra/-/fs-extra-8.1.1.tgz#1e49f22d09aa46e19b51c0b013cb63d0d923a068"
integrity sha512-TcUlBem321DFQzBNuz8p0CLLKp0VvF/XH9E4KHNmgwyp4E3AfgI5cjiIVZWlbfThBop2qxFIh4+LeY6hVWWZ2w==
dependencies:
"@types/node" "*"
"@types/fs-extra@^9.0.6":
version "9.0.9"
resolved "https://registry.yarnpkg.com/@types/fs-extra/-/fs-extra-9.0.9.tgz#11ed43b3f3c6b3490f1ef9bd17f58da896e2d861"
...
...
@@ -795,6 +802,14 @@
dependencies:
"@types/node" "*"
"@types/glob@^7.1.1":
version "7.1.3"
resolved "https://registry.yarnpkg.com/@types/glob/-/glob-7.1.3.tgz#e6ba80f36b7daad2c685acd9266382e68985c183"
integrity sha512-SEYeGAIQIQX8NN6LDKprLjbrd5dARM5EXsd8GI/A5l0apYI1fGMWgPHSe4ZKL4eozlAyI+doUE9XbYS4xCkQ1w==
dependencies:
"@types/minimatch" "*"
"@types/node" "*"
"@types/graceful-fs@^4.1.2":
version "4.1.5"
resolved "https://registry.yarnpkg.com/@types/graceful-fs/-/graceful-fs-4.1.5.tgz#21ffba0d98da4350db64891f92a9e5db3cdb4e15"
...
...
@@ -829,6 +844,11 @@
jest-diff "^26.0.0"
pretty-format "^26.0.0"
"@types/minimatch@*":
version "3.0.4"
resolved "https://registry.yarnpkg.com/@types/minimatch/-/minimatch-3.0.4.tgz#f0ec25dbf2f0e4b18647313ac031134ca5b24b21"
integrity sha512-1z8k4wzFnNjVK/tlxvrWuK5WMt6mydWWP7+zvH5eFep4oj+UkrfiJTRtjCeBXNpwaA/FYqqtb4/QS4ianFpIRA==
"@types/node@*", "@types/node@^14.14.20":
version "14.14.37"
resolved "https://registry.yarnpkg.com/@types/node/-/node-14.14.37.tgz#a3dd8da4eb84a996c36e331df98d82abd76b516e"
...
...
@@ -1800,7 +1820,7 @@ color-name@~1.1.4:
resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.4.tgz#c2a09a87acbde69543de6f63fa3995c826c536a2"
integrity sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==
colorette@^1.2.1, colorette@^1.2.2:
colorette@^1.
1.0, colorette@^1.
2.1, colorette@^1.2.2:
version "1.2.2"
resolved "https://registry.yarnpkg.com/colorette/-/colorette-1.2.2.tgz#cbcc79d5e99caea2dbf10eb3a26fd8b3e6acfa94"
integrity sha512-MKGMzyfeuutC/ZJ1cba9NqcNpfeqMUcYmyF1ZFY6/Cn7CNSAKx6a+s48sqLqyAiZuaP2TcqMhoo+dlwFnVxT9w==
...
...
@@ -2531,7 +2551,7 @@ fast-deep-equal@^3.1.1:
resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz#3a7d56b559d6cbc3eb512325244e619a65c6c525"
integrity sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==
fast-glob@^3.1.1:
fast-glob@^3.
0.3, fast-glob@^3.
1.1:
version "3.2.5"
resolved "https://registry.yarnpkg.com/fast-glob/-/fast-glob-3.2.5.tgz#7939af2a656de79a4f1901903ee8adcaa7cb9661"
integrity sha512-2DtFcgT68wiTTiwZ2hNdJfcHNke9XOfnwmBRWXhmeKM8rF0TGwmC/Qto3S7RoZKp5cilZbxzO5iTNTQsJ+EeDg==
...
...
@@ -2671,7 +2691,7 @@ fs-constants@^1.0.0:
resolved "https://registry.yarnpkg.com/fs-constants/-/fs-constants-1.0.0.tgz#6be0de9be998ce16af8afc24497b9ee9b7ccd9ad"
integrity sha512-y6OAwoSIf7FyjMIv94u+b5rdheZEjzR63GTyZJm5qh4Bi+2YgwLCcI/fPFZkL5PSixOt6ZNKm+w+Hfp/Bciwow==
fs-extra@8.1.0:
fs-extra@8.1.0
, fs-extra@^8.1.0
:
version "8.1.0"
resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-8.1.0.tgz#49d43c45a88cd9677668cb7be1b46efdb8d2e1c0"
integrity sha512-yhlQgA6mnOJUKOsRUFsgJdQCvkKhcz8tlZG5HBQfReYZy46OwLcY+Zia0mtdHsOo9y/hP+CxMN0TU9QxoOtG4g==
...
...
@@ -2831,6 +2851,20 @@ globals@^13.6.0:
dependencies:
type-fest "^0.20.2"
globby@10.0.1:
version "10.0.1"
resolved "https://registry.yarnpkg.com/globby/-/globby-10.0.1.tgz#4782c34cb75dd683351335c5829cc3420e606b22"
integrity sha512-sSs4inE1FB2YQiymcmTv6NWENryABjUNPeWhOvmn4SjtKybglsyPZxFB3U1/+L1bYi0rNZDqCLlHyLYDl1Pq5A==
dependencies:
"@types/glob" "^7.1.1"
array-union "^2.1.0"
dir-glob "^3.0.1"
fast-glob "^3.0.3"
glob "^7.1.3"
ignore "^5.1.1"
merge2 "^1.2.3"
slash "^3.0.0"
globby@^11.0.1, globby@^11.0.2:
version "11.0.3"
resolved "https://registry.yarnpkg.com/globby/-/globby-11.0.3.tgz#9b1f0cb523e171dd1ad8c7b2a9fb4b644b9593cb"
...
...
@@ -3026,7 +3060,7 @@ ignore@^4.0.6:
resolved "https://registry.yarnpkg.com/ignore/-/ignore-4.0.6.tgz#750e3db5862087b4737ebac8207ffd1ef27b25fc"
integrity sha512-cyFDKrqc/YdcWFniJhzI42+AzS+gNwmUzOSFcRCQYwySuBBBy/KjuxWLZ/FHEH6Moq1NizMOBWyTcv8O4OZIMg==
ignore@^5.1.4:
ignore@^5.1.
1, ignore@^5.1.
4:
version "5.1.8"
resolved "https://registry.yarnpkg.com/ignore/-/ignore-5.1.8.tgz#f150a8b50a34289b33e22f5889abd4d8016f0e57"
integrity sha512-BMpfD7PpiETpBl/A6S498BaIJ6Y/ABT93ETbby2fP00v4EbvPBXWEoaR1UBPKs3iR53pJY7EtZk5KACI57i1Uw==
...
...
@@ -3259,6 +3293,11 @@ is-plain-object@^2.0.3, is-plain-object@^2.0.4:
dependencies:
isobject "^3.0.1"
is-plain-object@^3.0.0:
version "3.0.1"
resolved "https://registry.yarnpkg.com/is-plain-object/-/is-plain-object-3.0.1.tgz#662d92d24c0aa4302407b0d45d21f2251c85f85b"
integrity sha512-Xnpx182SBMrr/aBik8y+GuR4U1L9FqMSojwDQwPMmxyC6bvEqly9UBCxhauBF5vNh2gwWJNX6oDV7O+OM4z34g==
is-potential-custom-element-name@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/is-potential-custom-element-name/-/is-potential-custom-element-name-1.0.0.tgz#0c52e54bcca391bb2c494b21e8626d7336c6e397"
...
...
@@ -4254,7 +4293,7 @@ merge-stream@^2.0.0:
resolved "https://registry.yarnpkg.com/merge-stream/-/merge-stream-2.0.0.tgz#52823629a14dd00c9770fb6ad47dc6310f2c1f60"
integrity sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w==
merge2@^1.3.0:
merge2@^1.
2.3, merge2@^1.
3.0:
version "1.4.1"
resolved "https://registry.yarnpkg.com/merge2/-/merge2-1.4.1.tgz#4368892f885e907455a6fd7dc55c0c9d404990ae"
integrity sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg==
...
...
@@ -5190,6 +5229,17 @@ ripemd160@^2.0.0, ripemd160@^2.0.1:
hash-base "^3.0.0"
inherits "^2.0.1"
rollup-plugin-copy@^3.4.0:
version "3.4.0"
resolved "https://registry.yarnpkg.com/rollup-plugin-copy/-/rollup-plugin-copy-3.4.0.tgz#f1228a3ffb66ffad8606e2f3fb7ff23141ed3286"
integrity sha512-rGUmYYsYsceRJRqLVlE9FivJMxJ7X6jDlP79fmFkL8sJs7VVMSVyA2yfyL+PGyO/vJs4A87hwhgVfz61njI+uQ==
dependencies:
"@types/fs-extra" "^8.0.1"
colorette "^1.1.0"
fs-extra "^8.1.0"
globby "10.0.1"
is-plain-object "^3.0.0"
rollup-plugin-node-builtins@^2.1.2:
version "2.1.2"
resolved "https://registry.yarnpkg.com/rollup-plugin-node-builtins/-/rollup-plugin-node-builtins-2.1.2.tgz#24a1fed4a43257b6b64371d8abc6ce1ab14597e9"
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录