Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Velpro187
uni-app
提交
8af8da50
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,发现更多精彩内容 >>
提交
8af8da50
编写于
1月 13, 2022
作者:
fxy060608
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
wip(app): nvue
上级
b56be6b3
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
63 addition
and
8 deletion
+63
-8
packages/uni-app-vite/package.json
packages/uni-app-vite/package.json
+2
-1
packages/uni-app-vite/src/nvue/index.ts
packages/uni-app-vite/src/nvue/index.ts
+2
-0
packages/uni-app-vite/src/nvue/plugins/esbuild.ts
packages/uni-app-vite/src/nvue/plugins/esbuild.ts
+57
-7
pnpm-lock.yaml
pnpm-lock.yaml
+2
-0
未找到文件。
packages/uni-app-vite/package.json
浏览文件 @
8af8da50
...
...
@@ -33,6 +33,7 @@
"devDependencies"
:
{
"@types/debug"
:
"^4.1.7"
,
"@types/fs-extra"
:
"^9.0.13"
,
"@vue/compiler-core"
:
"3.2.26"
"@vue/compiler-core"
:
"3.2.26"
,
"esbuild"
:
"^0.13.12"
}
}
packages/uni-app-vite/src/nvue/index.ts
浏览文件 @
8af8da50
...
...
@@ -7,6 +7,7 @@ import {
import
{
uniEasycomPlugin
}
from
'
../plugins/easycom
'
import
{
uniManifestJsonPlugin
}
from
'
../plugins/manifestJson
'
import
{
uniStatsPlugin
}
from
'
../plugins/stats
'
import
{
uniAppNVuePlugin
}
from
'
./plugin
'
import
{
uniEsbuildPlugin
}
from
'
./plugins/esbuild
'
import
{
uniMainJsPlugin
}
from
'
./plugins/mainJs
'
...
...
@@ -20,6 +21,7 @@ export function initNVuePlugins() {
...(
process
.
env
.
UNI_RENDERER
===
'
native
'
?
[
uniManifestJsonPlugin
()]
:
[]),
uniPagesJsonPlugin
(),
uniViteInjectPlugin
(
'
uni:app-inject
'
,
initAppProvide
()),
uniStatsPlugin
(),
uniAppNVuePlugin
(),
uniEsbuildPlugin
(),
]
...
...
packages/uni-app-vite/src/nvue/plugins/esbuild.ts
浏览文件 @
8af8da50
import
{
esbuild
}
from
'
@dcloudio/uni-cli-shared
'
import
path
from
'
path
'
import
fs
from
'
fs-extra
'
import
{
transformWithEsbuild
}
from
'
@dcloudio/uni-cli-shared
'
import
type
{
BuildOptions
,
PluginBuild
}
from
'
esbuild
'
import
type
{
Plugin
}
from
'
vite
'
import
{
nvueOutDir
}
from
'
../../utils
'
export
function
uniEsbuildPlugin
():
Plugin
{
let
buildOptions
:
BuildOptions
const
outputDir
=
process
.
env
.
UNI_OUTPUT_DIR
return
{
name
:
'
uni:app-nvue-esbuild
'
,
enforce
:
'
post
'
,
configResolved
(
config
)
{
buildOptions
=
{
format
:
'
iife
'
,
minify
:
config
.
build
.
minify
?
true
:
false
,
bundle
:
true
,
write
:
false
,
plugins
:
[
esbuildGlobalPlugin
({
vue
:
'
Vue
'
})],
}
},
async
writeBundle
(
_
,
bundle
)
{
const
entryPoints
:
string
[]
=
[]
Object
.
keys
(
bundle
).
forEach
((
name
)
=>
{
...
...
@@ -18,12 +32,48 @@ export function uniEsbuildPlugin(): Plugin {
entryPoints
.
push
(
name
)
}
})
await
esbuild
({
absWorkingDir
:
nvueOutDir
(),
entryPoints
,
bundle
:
true
,
external
:
[
'
vue
'
],
outdir
:
process
.
env
.
UNI_OUTPUT_DIR
,
await
Promise
.
all
(
entryPoints
.
map
((
filename
)
=>
{
return
buildNVuePage
(
filename
,
buildOptions
).
then
((
code
)
=>
{
return
fs
.
outputFile
(
path
.
resolve
(
outputDir
,
filename
),
code
)
})
})
)
},
}
}
function
buildNVuePage
(
filename
:
string
,
options
:
BuildOptions
)
{
return
transformWithEsbuild
(
`import NVuePageComponent from './
${
filename
}
'
Vue.createApp(NVuePageComponent).mount('#root')`
,
path
.
join
(
nvueOutDir
(),
'
main.js
'
),
options
).
then
((
res
)
=>
{
if
(
res
.
outputFiles
)
{
return
res
.
outputFiles
[
0
].
text
}
return
''
})
}
function
esbuildGlobalPlugin
(
options
:
Record
<
string
,
string
>
)
{
const
keys
=
Object
.
keys
(
options
)
return
{
name
:
'
global
'
,
setup
(
build
:
PluginBuild
)
{
keys
.
forEach
((
key
)
=>
{
const
namespace
=
key
+
'
-ns
'
build
.
onResolve
({
filter
:
new
RegExp
(
'
^
'
+
key
+
'
$
'
)
},
({
path
})
=>
{
return
{
path
,
namespace
,
}
})
build
.
onLoad
({
filter
:
/.*/
,
namespace
},
()
=>
({
contents
:
`module.exports =
${
options
[
key
]}
`
,
loader
:
'
js
'
,
}))
})
},
}
...
...
pnpm-lock.yaml
浏览文件 @
8af8da50
...
...
@@ -207,6 +207,7 @@ importers:
'
@vue/compiler-core'
:
3.2.26
'
@vue/compiler-sfc'
:
3.2.26
debug
:
^4.3.2
esbuild
:
^0.13.12
fs-extra
:
^10.0.0
rollup
:
^2.59.0
dependencies
:
...
...
@@ -224,6 +225,7 @@ importers:
'
@types/debug'
:
4.1.7
'
@types/fs-extra'
:
9.0.13
'
@vue/compiler-core'
:
3.2.26
esbuild
:
0.13.15
packages/uni-app-vue
:
specifiers
:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录