Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
qianlong66
uni-app
提交
67b3f505
U
uni-app
项目概览
qianlong66
/
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,发现更多精彩内容 >>
提交
67b3f505
编写于
1月 12, 2022
作者:
fxy060608
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
wip(app): nvue
上级
d5818428
变更
16
隐藏空白更改
内联
并排
Showing
16 changed file
with
171 addition
and
123 deletion
+171
-123
packages/uni-app-vite/src/vue/index.ts
packages/uni-app-vite/src/vue/index.ts
+1
-1
packages/uni-app/dist/uni.compiler.js
packages/uni-app/dist/uni.compiler.js
+3
-3
packages/uni-app/src/compiler/index.ts
packages/uni-app/src/compiler/index.ts
+3
-3
packages/uni-cli-shared/__tests__/inject.spec.ts
packages/uni-cli-shared/__tests__/inject.spec.ts
+2
-2
packages/uni-cli-shared/src/vite/plugins/inject.ts
packages/uni-cli-shared/src/vite/plugins/inject.ts
+5
-2
packages/uni-cli-shared/src/vite/utils/utils.ts
packages/uni-cli-shared/src/vite/utils/utils.ts
+5
-1
packages/uni-cloud/lib/uni.plugin.js
packages/uni-cloud/lib/uni.plugin.js
+50
-44
packages/uni-cloud/src/uni.plugin.ts
packages/uni-cloud/src/uni.plugin.ts
+58
-50
packages/uni-h5-vite/src/index.ts
packages/uni-h5-vite/src/index.ts
+4
-1
packages/uni-h5-vite/src/plugins/inject.ts
packages/uni-h5-vite/src/plugins/inject.ts
+1
-0
packages/uni-mp-vite/src/index.ts
packages/uni-mp-vite/src/index.ts
+1
-1
packages/uni-stat/lib/uni.plugin.js
packages/uni-stat/lib/uni.plugin.js
+4
-2
packages/uni-stat/src/plugin/index.ts
packages/uni-stat/src/plugin/index.ts
+4
-2
packages/vite-plugin-uni/src/configResolved/index.ts
packages/vite-plugin-uni/src/configResolved/index.ts
+8
-2
packages/vite-plugin-uni/src/configResolved/plugins/preVue.ts
...ages/vite-plugin-uni/src/configResolved/plugins/preVue.ts
+10
-3
packages/vite-plugin-uni/src/index.ts
packages/vite-plugin-uni/src/index.ts
+12
-6
未找到文件。
packages/uni-app-vite/src/vue/index.ts
浏览文件 @
67b3f505
...
...
@@ -42,7 +42,7 @@ export function initVuePlugins() {
uniMainJsPlugin
(),
uniManifestJsonPlugin
(),
uniPagesJsonPlugin
(),
uniViteInjectPlugin
(
initAppProvide
()),
uniViteInjectPlugin
(
'
uni:app-inject
'
,
initAppProvide
()),
uniRenderjsPlugin
(),
uniTemplatePlugin
(),
uniStatsPlugin
(),
...
...
packages/uni-app/dist/uni.compiler.js
浏览文件 @
67b3f505
'
use strict
'
;
var
index
=
[
var
index
=
()
=>
[
/* eslint-disable no-restricted-globals */
...
require
(
'
@dcloudio/uni-cloud/lib/uni.plugin.js
'
).
default
,
...
require
(
'
@dcloudio/uni-cloud/lib/uni.plugin.js
'
).
default
()
,
/* eslint-disable no-restricted-globals */
...
require
(
'
@dcloudio/uni-stat/lib/uni.plugin.js
'
),
...
require
(
'
@dcloudio/uni-stat/lib/uni.plugin.js
'
)
()
,
];
module
.
exports
=
index
;
packages/uni-app/src/compiler/index.ts
浏览文件 @
67b3f505
export
default
[
export
default
()
=>
[
/* eslint-disable no-restricted-globals */
...
require
(
'
@dcloudio/uni-cloud/lib/uni.plugin.js
'
).
default
,
...
require
(
'
@dcloudio/uni-cloud/lib/uni.plugin.js
'
).
default
()
,
/* eslint-disable no-restricted-globals */
...
require
(
'
@dcloudio/uni-stat/lib/uni.plugin.js
'
),
...
require
(
'
@dcloudio/uni-stat/lib/uni.plugin.js
'
)
()
,
]
packages/uni-cli-shared/__tests__/inject.spec.ts
浏览文件 @
67b3f505
...
...
@@ -18,7 +18,7 @@ describe('inject', () => {
parse
:
(
code
:
string
)
=>
parse
(
code
).
program
,
}
as
unknown
as
TransformPluginContext
test
(
`basic`
,
()
=>
{
const
plugin
=
uniViteInjectPlugin
(
injectOptions
)
const
plugin
=
uniViteInjectPlugin
(
'
uni:inject
'
,
injectOptions
)
expect
(
(
plugin
.
transform
!
.
call
(
...
...
@@ -30,7 +30,7 @@ describe('inject', () => {
).
toMatchSnapshot
()
})
test
(
`reassignment`
,
()
=>
{
const
plugin
=
uniViteInjectPlugin
(
injectOptions
)
const
plugin
=
uniViteInjectPlugin
(
'
uni:inject
'
,
injectOptions
)
expect
(
(
plugin
.
transform
!
.
call
(
...
...
packages/uni-cli-shared/src/vite/plugins/inject.ts
浏览文件 @
67b3f505
...
...
@@ -42,7 +42,10 @@ export interface InjectOptions {
const
debugInject
=
debug
(
'
uni:inject
'
)
const
debugInjectTry
=
debug
(
'
uni:inject-try
'
)
export
function
uniViteInjectPlugin
(
options
:
InjectOptions
):
Plugin
{
export
function
uniViteInjectPlugin
(
name
:
string
,
options
:
InjectOptions
):
Plugin
{
if
(
!
options
)
throw
new
Error
(
'
Missing options
'
)
const
filter
=
createFilter
(
options
.
include
,
options
.
exclude
)
...
...
@@ -76,7 +79,7 @@ export function uniViteInjectPlugin(options: InjectOptions): Plugin {
const
sourceMap
=
options
.
sourceMap
!==
false
const
callback
=
options
.
callback
return
{
name
:
'
uni:inject
'
,
name
,
// 确保在 commonjs 之后,否则会混合 es6 module 与 cjs 的代码,导致 commonjs 失效
enforce
:
'
post
'
,
transform
(
code
,
id
)
{
...
...
packages/uni-cli-shared/src/vite/utils/utils.ts
浏览文件 @
67b3f505
import
type
{
ResolvedConfig
}
from
'
vite
'
import
type
{
ResolvedConfig
,
UserConfig
}
from
'
vite
'
export
function
withSourcemap
(
config
:
ResolvedConfig
)
{
if
(
config
.
command
===
'
serve
'
)
{
...
...
@@ -6,3 +6,7 @@ export function withSourcemap(config: ResolvedConfig) {
}
return
!!
config
.
build
.
sourcemap
}
export
function
isInHybridNVue
(
config
:
UserConfig
|
ResolvedConfig
):
boolean
{
return
(
config
as
any
).
nvue
&&
process
.
env
.
UNI_RENDERER
!==
'
native
'
}
packages/uni-cloud/lib/uni.plugin.js
浏览文件 @
67b3f505
...
...
@@ -5,51 +5,57 @@ const uni_cli_shared_1 = require("@dcloudio/uni-cli-shared");
const
validateFunction_1
=
require
(
"
./validateFunction
"
);
process
.
env
.
UNI_CLOUD_PROVIDER
=
JSON
.
stringify
([]);
const
uniCloudSpaces
=
[];
initUniCloudEnv
();
const
initUniCloudEnvOnce
=
(
0
,
uni_shared_1
.
once
)(
initUniCloudEnv
);
initUniCloudEnvOnce
();
/**
* @type {import('vite').Plugin}
*/
const
UniCloudPlugin
=
{
name
:
'
uni:cloud
'
,
config
(
config
)
{
const
silent
=
config
.
build
&&
config
.
build
.
ssr
?
true
:
false
;
if
(
silent
)
{
return
;
}
const
len
=
uniCloudSpaces
.
length
;
if
(
!
len
)
{
return
;
}
if
(
len
===
1
)
{
console
.
log
(
`本项目的uniCloud使用的默认服务空间spaceId为:
${
uniCloudSpaces
[
0
].
id
}
`
);
}
if
(
process
.
env
.
UNI_PLATFORM
===
'
h5
'
&&
!
process
.
env
.
UNI_SUB_PLATFORM
&&
process
.
env
.
NODE_ENV
===
'
production
'
)
{
console
.
warn
(
'
发布H5,需要在uniCloud后台操作,绑定安全域名,否则会因为跨域问题而无法访问。教程参考:https://uniapp.dcloud.io/uniCloud/quickstart?id=useinh5
'
);
}
return
{};
},
configureServer
(
server
)
{
if
(
server
.
httpServer
)
{
server
.
httpServer
.
on
(
'
listening
'
,
()
=>
{
process
.
nextTick
(()
=>
{
initUniCloudWarningOnce
();
function
uniCloudPlugin
()
{
return
{
name
:
'
uni:cloud
'
,
config
(
config
)
{
const
silent
=
config
.
build
&&
config
.
build
.
ssr
?
true
:
false
;
if
(
silent
)
{
return
;
}
const
len
=
uniCloudSpaces
.
length
;
if
(
!
len
)
{
return
;
}
if
((
0
,
uni_cli_shared_1
.
isInHybridNVue
)(
config
))
{
return
;
}
if
(
len
===
1
)
{
console
.
log
(
`本项目的uniCloud使用的默认服务空间spaceId为:
${
uniCloudSpaces
[
0
].
id
}
`
);
}
if
(
process
.
env
.
UNI_PLATFORM
===
'
h5
'
&&
!
process
.
env
.
UNI_SUB_PLATFORM
&&
process
.
env
.
NODE_ENV
===
'
production
'
)
{
console
.
warn
(
'
发布H5,需要在uniCloud后台操作,绑定安全域名,否则会因为跨域问题而无法访问。教程参考:https://uniapp.dcloud.io/uniCloud/quickstart?id=useinh5
'
);
}
return
{};
},
configureServer
(
server
)
{
if
(
server
.
httpServer
)
{
server
.
httpServer
.
on
(
'
listening
'
,
()
=>
{
process
.
nextTick
(()
=>
{
initUniCloudWarningOnce
();
});
});
}
);
}
else
{
initUniCloudWarningOnce
();
}
},
closeBundle
(
)
{
if
(
process
.
env
.
UNI_PLATFORM
===
'
h5
'
&&
!
process
.
env
.
UNI_SSR_CLIENT
)
{
console
.
log
(
);
console
.
log
(
'
欢迎将H5站部署到uniCloud前端网页托管平台,高速、免费、安全、省心,详见:
'
);
console
.
log
(
'
https://uniapp.dcloud.io/uniCloud/hosting
'
);
}
}
,
}
;
}
else
{
initUniCloudWarningOnce
();
}
}
,
closeBundle
()
{
if
(
process
.
env
.
UNI_PLATFORM
===
'
h5
'
&&
!
process
.
env
.
UNI_SSR_CLIENT
)
{
console
.
log
();
console
.
log
(
'
欢迎将H5站部署到uniCloud前端网页托管平台,高速、免费、安全、省心,详见:
'
);
console
.
log
(
'
https://uniapp.dcloud.io/uniCloud/hosting
'
);
}
}
,
}
;
}
const
initUniCloudWarningOnce
=
(
0
,
uni_shared_1
.
once
)(()
=>
{
uniCloudSpaces
.
length
&&
console
.
warn
(
'
当前项目使用了uniCloud,为避免云函数调用跨域问题,建议在HBuilderX内置浏览器里调试,如使用外部浏览器需处理跨域,详见:https://uniapp.dcloud.io/uniCloud/quickstart?id=useinh5
'
);
...
...
@@ -85,9 +91,9 @@ function initUniCloudEnv() {
}
catch
(
e
)
{
}
}
exports
.
default
=
[
UniCloudPlugin
,
(
0
,
uni_cli_shared_1
.
uniViteInjectPlugin
)({
exports
.
default
=
()
=>
[
uniCloudPlugin
()
,
(
0
,
uni_cli_shared_1
.
uniViteInjectPlugin
)(
'
uni:cloud-inject
'
,
{
exclude
:
[...
uni_cli_shared_1
.
COMMON_EXCLUDE
],
uniCloud
:
[
'
@dcloudio/uni-cloud
'
,
'
default
'
],
}),
...
...
packages/uni-cloud/src/uni.plugin.ts
浏览文件 @
67b3f505
import
{
once
}
from
'
@dcloudio/uni-shared
'
import
{
COMMON_EXCLUDE
,
isInHybridNVue
,
uniViteInjectPlugin
,
UniVitePlugin
,
}
from
'
@dcloudio/uni-cli-shared
'
...
...
@@ -17,58 +18,65 @@ const uniCloudSpaces: {
apiEndpoint
?:
string
}[]
=
[]
initUniCloudEnv
()
const
initUniCloudEnvOnce
=
once
(
initUniCloudEnv
)
initUniCloudEnvOnce
()
/**
* @type {import('vite').Plugin}
*/
const
UniCloudPlugin
:
UniVitePlugin
=
{
name
:
'
uni:cloud
'
,
config
(
config
)
{
const
silent
=
config
.
build
&&
config
.
build
.
ssr
?
true
:
false
if
(
silent
)
{
return
}
const
len
=
uniCloudSpaces
.
length
if
(
!
len
)
{
return
}
if
(
len
===
1
)
{
console
.
log
(
`本项目的uniCloud使用的默认服务空间spaceId为:
${
uniCloudSpaces
[
0
].
id
}
`
)
}
if
(
process
.
env
.
UNI_PLATFORM
===
'
h5
'
&&
!
process
.
env
.
UNI_SUB_PLATFORM
&&
process
.
env
.
NODE_ENV
===
'
production
'
)
{
console
.
warn
(
'
发布H5,需要在uniCloud后台操作,绑定安全域名,否则会因为跨域问题而无法访问。教程参考:https://uniapp.dcloud.io/uniCloud/quickstart?id=useinh5
'
)
}
return
{}
},
configureServer
(
server
)
{
if
(
server
.
httpServer
)
{
server
.
httpServer
.
on
(
'
listening
'
,
()
=>
{
process
.
nextTick
(()
=>
{
initUniCloudWarningOnce
()
function
uniCloudPlugin
():
UniVitePlugin
{
return
{
name
:
'
uni:cloud
'
,
config
(
config
)
{
const
silent
=
config
.
build
&&
config
.
build
.
ssr
?
true
:
false
if
(
silent
)
{
return
}
const
len
=
uniCloudSpaces
.
length
if
(
!
len
)
{
return
}
if
(
isInHybridNVue
(
config
))
{
return
}
if
(
len
===
1
)
{
console
.
log
(
`本项目的uniCloud使用的默认服务空间spaceId为:
${
uniCloudSpaces
[
0
].
id
}
`
)
}
if
(
process
.
env
.
UNI_PLATFORM
===
'
h5
'
&&
!
process
.
env
.
UNI_SUB_PLATFORM
&&
process
.
env
.
NODE_ENV
===
'
production
'
)
{
console
.
warn
(
'
发布H5,需要在uniCloud后台操作,绑定安全域名,否则会因为跨域问题而无法访问。教程参考:https://uniapp.dcloud.io/uniCloud/quickstart?id=useinh5
'
)
}
return
{}
},
configureServer
(
server
)
{
if
(
server
.
httpServer
)
{
server
.
httpServer
.
on
(
'
listening
'
,
()
=>
{
process
.
nextTick
(()
=>
{
initUniCloudWarningOnce
()
})
})
}
)
}
else
{
initUniCloudWarningOnce
()
}
},
closeBundle
(
)
{
if
(
process
.
env
.
UNI_PLATFORM
===
'
h5
'
&&
!
process
.
env
.
UNI_SSR_CLIENT
)
{
console
.
log
()
console
.
log
(
'
欢迎将H5站部署到uniCloud前端网页托管平台,高速、免费、安全、省心,详见:
'
)
console
.
log
(
'
https://uniapp.dcloud.io/uniCloud/hosting
'
)
}
}
,
}
else
{
initUniCloudWarningOnce
()
}
}
,
closeBundle
()
{
if
(
process
.
env
.
UNI_PLATFORM
===
'
h5
'
&&
!
process
.
env
.
UNI_SSR_CLIENT
)
{
console
.
log
()
console
.
log
(
'
欢迎将H5站部署到uniCloud前端网页托管平台,高速、免费、安全、省心,详见:
'
)
console
.
log
(
'
https://uniapp.dcloud.io/uniCloud/hosting
'
)
}
}
,
}
}
const
initUniCloudWarningOnce
=
once
(()
=>
{
...
...
@@ -110,9 +118,9 @@ function initUniCloudEnv() {
}
catch
(
e
)
{}
}
export
default
[
UniCloudPlugin
,
uniViteInjectPlugin
({
export
default
()
=>
[
uniCloudPlugin
()
,
uniViteInjectPlugin
(
'
uni:cloud-inject
'
,
{
exclude
:
[...
COMMON_EXCLUDE
],
uniCloud
:
[
'
@dcloudio/uni-cloud
'
,
'
default
'
],
}),
...
...
packages/uni-h5-vite/src/index.ts
浏览文件 @
67b3f505
...
...
@@ -25,7 +25,10 @@ export default [
}),
uniResolveIdPlugin
(),
...(
process
.
env
.
UNI_H5_BROWSER
===
'
builtin
'
?
[
uniViteInjectPlugin
(
initH5Provide
()),
uniHBuilderXConsolePlugin
()]
?
[
uniViteInjectPlugin
(
'
uni:h5-inject-hbx
'
,
initH5Provide
()),
uniHBuilderXConsolePlugin
(),
]
:
[]),
uniMainJsPlugin
(),
uniManifestJsonPlugin
(),
...
...
packages/uni-h5-vite/src/plugins/inject.ts
浏览文件 @
67b3f505
...
...
@@ -68,6 +68,7 @@ export function uniInjectPlugin(): Plugin {
delete
uniInjectPluginOptions
[
'
uni.
'
]
}
injectPlugin
=
uniViteInjectPlugin
(
'
uni:h5-inject
'
,
extend
(
uniInjectPluginOptions
,
{
callback
,
})
...
...
packages/uni-mp-vite/src/index.ts
浏览文件 @
67b3f505
...
...
@@ -31,7 +31,7 @@ export default (options: UniMiniProgramPluginOptions) => {
uniManifestJsonPlugin
(
options
),
uniPagesJsonPlugin
(
options
),
uniEntryPlugin
(
options
),
uniViteInjectPlugin
(
extend
({},
options
.
vite
.
inject
)),
uniViteInjectPlugin
(
'
uni:mp-inject
'
,
extend
({},
options
.
vite
.
inject
)),
uniRenderjsPlugin
({
lang
:
options
.
template
.
filter
?.
lang
}),
uniRuntimeHooksPlugin
(),
uniMiniProgramPlugin
(
options
),
...
...
packages/uni-stat/lib/uni.plugin.js
浏览文件 @
67b3f505
...
...
@@ -7,9 +7,10 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
var
debug__default
=
/*#__PURE__*/
_interopDefaultLegacy
(
debug
);
var
index
=
[
var
index
=
()
=>
[
uniCliShared
.
defineUniMainJsPlugin
((
opts
)
=>
{
let
isEnable
=
false
;
let
isNVue
=
false
;
return
{
name
:
'
uni:stat
'
,
enforce
:
'
pre
'
,
...
...
@@ -17,6 +18,7 @@ var index = [
if
(
isSsr
(
env
.
command
,
config
))
{
return
;
}
isNVue
=
config
.
nvue
;
const
inputDir
=
process
.
env
.
UNI_INPUT_DIR
;
const
platform
=
process
.
env
.
UNI_PLATFORM
;
isEnable
=
uniCliShared
.
getUniStatistics
(
inputDir
,
platform
).
enable
===
true
;
...
...
@@ -55,7 +57,7 @@ var index = [
};
},
transform
(
code
,
id
)
{
if
(
isEnable
&&
opts
.
filter
(
id
))
{
if
(
isEnable
&&
!
isNVue
&&
opts
.
filter
(
id
))
{
return
{
code
:
code
+
`;import '@dcloudio/uni-stat';`
,
map
:
null
,
...
...
packages/uni-stat/src/plugin/index.ts
浏览文件 @
67b3f505
...
...
@@ -8,9 +8,10 @@ import {
parsePagesJson
,
}
from
'
@dcloudio/uni-cli-shared
'
export
default
[
export
default
()
=>
[
defineUniMainJsPlugin
((
opts
)
=>
{
let
isEnable
=
false
let
isNVue
=
false
return
{
name
:
'
uni:stat
'
,
enforce
:
'
pre
'
,
...
...
@@ -18,6 +19,7 @@ export default [
if
(
isSsr
(
env
.
command
,
config
))
{
return
}
isNVue
=
(
config
as
any
).
nvue
const
inputDir
=
process
.
env
.
UNI_INPUT_DIR
!
const
platform
=
process
.
env
.
UNI_PLATFORM
!
isEnable
=
getUniStatistics
(
inputDir
,
platform
).
enable
===
true
...
...
@@ -54,7 +56,7 @@ export default [
}
},
transform
(
code
,
id
)
{
if
(
isEnable
&&
opts
.
filter
(
id
))
{
if
(
isEnable
&&
!
isNVue
&&
opts
.
filter
(
id
))
{
return
{
code
:
code
+
`;import '@dcloudio/uni-stat';`
,
map
:
null
,
...
...
packages/vite-plugin-uni/src/configResolved/index.ts
浏览文件 @
67b3f505
...
...
@@ -6,6 +6,7 @@ import {
formatErrMsg
,
formatInfoMsg
,
formatWarnMsg
,
isInHybridNVue
,
}
from
'
@dcloudio/uni-cli-shared
'
import
{
VitePluginUniResolvedOptions
}
from
'
..
'
...
...
@@ -16,11 +17,16 @@ import { customResolver } from '../config/resolve'
export
function
createConfigResolved
(
options
:
VitePluginUniResolvedOptions
)
{
return
((
config
)
=>
{
initEnv
(
config
)
// 如果是混合编译且是 nvue 时,部分逻辑无需执行
if
(
!
isInHybridNVue
(
config
))
{
initEnv
(
config
)
}
initLogger
(
config
)
initOptions
(
options
,
config
)
initPlugins
(
config
,
options
)
initCheckUpdate
()
if
(
!
isInHybridNVue
(
config
))
{
initCheckUpdate
()
}
if
(
isWindows
)
{
// TODO 等 https://github.com/vitejs/vite/issues/3331 修复后,可以移除下列代码
const
item
=
config
.
resolve
.
alias
.
find
((
item
)
=>
...
...
packages/vite-plugin-uni/src/configResolved/plugins/preVue.ts
浏览文件 @
67b3f505
...
...
@@ -30,8 +30,12 @@ const WXS_LANG_RE = /lang=["|'](renderjs|wxs)["|']/
const
WXS_ATTRS
=
[
'
wxs
'
,
'
renderjs
'
]
export
function
uniPreVuePlugin
():
Plugin
{
let
isNVue
=
false
return
{
name
:
'
uni:pre-vue
'
,
config
(
config
)
{
isNVue
=
(
config
as
any
).
nvue
},
async
transform
(
code
,
id
)
{
const
{
filename
,
query
}
=
parseVueRequest
(
id
)
if
(
query
.
vue
)
{
...
...
@@ -45,7 +49,8 @@ export function uniPreVuePlugin(): Plugin {
removeExt
(
normalizeMiniProgramFilename
(
id
,
process
.
env
.
UNI_INPUT_DIR
))
)
const
hasBlock
=
BLOCK_RE
.
test
(
code
)
const
hasWxs
=
WXS_LANG_RE
.
test
(
code
)
// nvue 不支持 renderjs,wxs
const
hasWxs
=
!
isNVue
&&
WXS_LANG_RE
.
test
(
code
)
if
(
!
hasBlock
&&
!
hasWxs
)
{
return
}
...
...
@@ -55,10 +60,12 @@ export function uniPreVuePlugin(): Plugin {
let
ast
=
parseVue
(
code
,
errors
)
if
(
hasBlock
)
{
code
=
parseBlockCode
(
ast
,
code
)
// 重新解析新的 code
ast
=
parseVue
(
code
,
errors
)
}
if
(
hasWxs
)
{
if
(
hasBlock
)
{
// 重新解析新的 code
ast
=
parseVue
(
code
,
errors
)
}
const
wxsNodes
=
parseWxsNodes
(
ast
)
code
=
parseWxsCode
(
wxsNodes
,
code
)
// add watch
...
...
packages/vite-plugin-uni/src/index.ts
浏览文件 @
67b3f505
...
...
@@ -136,12 +136,18 @@ export default function uniPlugin(
vuePlugin
(
initPluginVueOptions
(
options
,
uniPlugins
,
uniPluginOptions
))
)
plugins
.
push
(
uniCopyPlugin
({
outputDir
:
process
.
env
.
UNI_OUTPUT_DIR
,
copyOptions
:
options
.
copyOptions
,
})
)
// 混合编译时,nvue 下,不需要 copy
if
(
process
.
env
.
UNI_RENDERER
===
'
native
'
||
process
.
env
.
UNI_COMPILER
===
'
vue
'
)
{
plugins
.
push
(
uniCopyPlugin
({
outputDir
:
process
.
env
.
UNI_OUTPUT_DIR
,
copyOptions
:
options
.
copyOptions
,
})
)
}
return
plugins
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录