Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Velpro187
uni-app
提交
4b6505e2
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,发现更多精彩内容 >>
提交
4b6505e2
编写于
4月 27, 2021
作者:
fxy060608
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat(easycom): support uni_modules
上级
b4b23e70
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
53 addition
and
20 deletion
+53
-20
packages/vite-plugin-uni/src/config/build.ts
packages/vite-plugin-uni/src/config/build.ts
+2
-1
packages/vite-plugin-uni/src/config/css.ts
packages/vite-plugin-uni/src/config/css.ts
+13
-1
packages/vite-plugin-uni/src/configResolved/plugins/cssScoped.ts
...s/vite-plugin-uni/src/configResolved/plugins/cssScoped.ts
+1
-1
packages/vite-plugin-uni/src/configureServer/easycom.ts
packages/vite-plugin-uni/src/configureServer/easycom.ts
+1
-16
packages/vite-plugin-uni/src/utils/easycom.ts
packages/vite-plugin-uni/src/utils/easycom.ts
+36
-1
未找到文件。
packages/vite-plugin-uni/src/config/build.ts
浏览文件 @
4b6505e2
...
...
@@ -2,12 +2,13 @@ import path from 'path'
import
slash
from
'
slash
'
import
{
UserConfig
}
from
'
vite
'
import
{
VitePluginUniResolvedOptions
}
from
'
..
'
import
{
FEATURE_DEFINES
}
from
'
../utils
'
import
{
FEATURE_DEFINES
,
initEasycoms
}
from
'
../utils
'
export
function
createBuild
(
options
:
VitePluginUniResolvedOptions
,
features
:
FEATURE_DEFINES
):
UserConfig
[
'
build
'
]
{
initEasycoms
(
options
.
inputDir
)
return
{
polyfillDynamicImport
:
features
.
__UNI_FEATURE_PAGES__
,
rollupOptions
:
{
...
...
packages/vite-plugin-uni/src/config/css.ts
浏览文件 @
4b6505e2
import
path
from
'
path
'
import
fs
from
'
fs-extra
'
import
{
UserConfig
}
from
'
vite
'
import
autoprefixer
from
'
autoprefixer
'
import
{
VitePluginUniResolvedOptions
}
from
'
..
'
import
{
uniapp
}
from
'
../utils
'
function
resolveAdditionalData
(
inputDir
:
string
)
{
const
uniScssFile
=
path
.
resolve
(
inputDir
,
'
uni.scss
'
)
if
(
!
fs
.
existsSync
(
uniScssFile
))
{
return
''
}
return
fs
.
readFileSync
(
uniScssFile
,
'
utf8
'
)
}
export
function
createCss
(
options
:
VitePluginUniResolvedOptions
):
UserConfig
[
'
css
'
]
{
...
...
@@ -14,7 +24,9 @@ export function createCss(
],
},
preprocessorOptions
:
{
scss
:
{},
scss
:
{
additionalData
:
resolveAdditionalData
(
options
.
inputDir
),
},
},
}
}
packages/vite-plugin-uni/src/configResolved/plugins/cssScoped.ts
浏览文件 @
4b6505e2
...
...
@@ -8,7 +8,7 @@ import { UniPluginFilterOptions } from '.'
const
debugScoped
=
debug
(
'
uni:scoped
'
)
const
SCOPED_RE
=
/<style
\s[^
>
]
*scoped
[^
>
]
*>/
g
i
const
SCOPED_RE
=
/<style
\s[^
>
]
*scoped
[^
>
]
*>/i
function
addScoped
(
code
:
string
)
{
if
(
SCOPED_RE
.
test
(
code
))
{
...
...
packages/vite-plugin-uni/src/configureServer/easycom.ts
浏览文件 @
4b6505e2
import
path
from
'
path
'
import
{
ViteDevServer
}
from
'
vite
'
import
{
VitePluginUniResolvedOptions
}
from
'
..
'
import
{
debugEasycom
,
initEasycom
}
from
'
../utils
'
function
initEasycoms
(
inputDir
:
string
)
{
const
dirs
=
[
'
components
'
].
map
((
dir
)
=>
path
.
resolve
(
inputDir
,
dir
))
const
easycomOptions
=
{
dirs
,
rootDir
:
inputDir
}
initEasycom
(
easycomOptions
)
debugEasycom
(
easycomOptions
)
return
{
dirs
,
refresh
()
{
initEasycom
(
easycomOptions
)
},
}
}
import
{
initEasycoms
}
from
'
../utils
'
export
const
serveEasycom
=
(
server
:
ViteDevServer
,
...
...
packages/vite-plugin-uni/src/utils/easycom.ts
浏览文件 @
4b6505e2
...
...
@@ -31,7 +31,42 @@ function clearEasycom() {
easycomsInvalidCache
.
clear
()
}
export
function
initEasycom
({
export
function
initEasycoms
(
inputDir
:
string
)
{
const
dirs
=
[
'
components
'
]
.
map
((
dir
)
=>
path
.
resolve
(
inputDir
,
dir
))
.
concat
(
initUniModulesEasycomDirs
(
inputDir
))
const
easycomOptions
=
{
dirs
,
rootDir
:
inputDir
}
initEasycom
(
easycomOptions
)
debugEasycom
(
easycomOptions
)
return
{
dirs
,
refresh
()
{
initEasycom
(
easycomOptions
)
},
}
}
function
initUniModulesEasycomDirs
(
inputDir
:
string
)
{
const
uniModulesDir
=
path
.
resolve
(
inputDir
,
'
uni_modules
'
)
if
(
!
fs
.
existsSync
(
uniModulesDir
))
{
return
[]
}
return
fs
.
readdirSync
(
uniModulesDir
)
.
map
((
uniModuleDir
)
=>
{
const
uniModuleComponentsDir
=
path
.
resolve
(
uniModulesDir
,
uniModuleDir
,
'
components
'
)
if
(
fs
.
existsSync
(
uniModuleComponentsDir
))
{
return
uniModuleComponentsDir
}
})
.
filter
<
string
>
(
Boolean
as
any
)
}
function
initEasycom
({
dirs
,
rootDir
,
custom
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录