Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
uni-app
提交
191f250e
U
uni-app
项目概览
DCloud
/
uni-app
6 个月 前同步成功
通知
751
Star
38709
Fork
3642
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
8
列表
看板
标记
里程碑
合并请求
1
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
uni-app
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
8
Issue
8
列表
看板
标记
里程碑
合并请求
1
合并请求
1
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
191f250e
编写于
4月 20, 2023
作者:
fxy060608
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
chore: merge
上级
1f1015b1
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
55 addition
and
28 deletion
+55
-28
packages/uni-app-uts/src/plugins/css.ts
packages/uni-app-uts/src/plugins/css.ts
+33
-13
packages/uni-cli-shared/src/vite/plugins/mainJs.ts
packages/uni-cli-shared/src/vite/plugins/mainJs.ts
+3
-1
packages/uni-cli-shared/src/vite/plugins/vitejs/plugins/css.ts
...ges/uni-cli-shared/src/vite/plugins/vitejs/plugins/css.ts
+1
-11
packages/uni-cli-shared/src/vite/utils/plugin.ts
packages/uni-cli-shared/src/vite/utils/plugin.ts
+11
-0
packages/uni-mp-lark/dist/uni.compiler.js
packages/uni-mp-lark/dist/uni.compiler.js
+1
-1
packages/uni-nvue-styler/src/parse.ts
packages/uni-nvue-styler/src/parse.ts
+5
-1
packages/uni-nvue-styler/tsconfig.json
packages/uni-nvue-styler/tsconfig.json
+1
-1
未找到文件。
packages/uni-app-uts/src/plugins/css.ts
浏览文件 @
191f250e
...
...
@@ -9,6 +9,7 @@ import {
cssPostPlugin
,
formatAtFilename
,
generateCodeFrame
,
insertBeforePlugin
,
normalizePath
,
parseVueRequest
,
resolveMainPathOnce
,
...
...
@@ -20,14 +21,12 @@ import { genClassName, isVue } from './utils'
export
function
uniAppCssPlugin
():
Plugin
{
const
mainUTS
=
resolveMainPathOnce
(
process
.
env
.
UNI_INPUT_DIR
)
let
resolvedConfig
:
ResolvedConfig
const
name
=
'
uni:app-uvue-css
'
return
{
name
:
'
uni:app-uvue-css
'
,
name
,
apply
:
'
build
'
,
configResolved
(
config
)
{
resolvedConfig
=
config
const
plugins
=
config
.
plugins
as
Plugin
[]
// 增加 css plugins
plugins
.
push
(
cssPlugin
(
config
))
const
uvueCssPostPlugin
=
cssPostPlugin
(
config
,
{
isJsCode
:
true
,
platform
:
process
.
env
.
UNI_PLATFORM
,
...
...
@@ -42,25 +41,46 @@ export function uniAppCssPlugin(): Plugin {
)
}
},
chunkCssCode
(
filename
,
cssCode
)
{
return
(
`export const
${
genClassName
(
filename
.
replace
(
'
.style.uts
'
,
''
)
)}
Styles = `
+
cssCode
)
async
chunkCssCode
(
filename
,
cssCode
)
{
const
{
code
,
messages
}
=
await
parse
(
cssCode
,
{
filename
,
logLevel
:
'
ERROR
'
,
map
:
true
,
ts
:
true
,
})
messages
.
forEach
((
message
)
=>
{
if
(
message
.
type
===
'
error
'
)
{
let
msg
=
`[plugin:uni:app-uvue-css]
${
message
.
text
}
`
if
(
message
.
line
&&
message
.
column
)
{
msg
+=
`\n
${
generateCodeFrame
(
cssCode
,
{
line
:
message
.
line
,
column
:
message
.
column
,
})}
`
}
msg
+=
`\n
${
formatAtFilename
(
filename
)}
`
resolvedConfig
.
logger
.
error
(
colors
.
red
(
msg
))
}
})
return
`export const
${
genClassName
(
filename
.
replace
(
'
.style.uts
'
,
''
)
)}
Styles = [
${
code
}
]`
},
})
plugins
.
push
(
uvueCssPostPlugin
)
// 增加 css plugins
insertBeforePlugin
(
cssPlugin
(
config
),
name
,
config
)
;(
config
.
plugins
as
Plugin
[]).
push
(
uvueCssPostPlugin
)
},
async
transform
(
source
,
filename
)
{
if
(
!
cssLangRE
.
test
(
filename
)
||
commonjsProxyRE
.
test
(
filename
))
{
return
}
const
{
code
,
messages
}
=
await
parse
(
source
,
{
// 仅做校验使用
const
{
messages
}
=
await
parse
(
source
,
{
filename
,
logLevel
:
'
WARNING
'
,
map
:
true
,
ts
:
true
,
noCode
:
true
,
})
messages
.
forEach
((
message
)
=>
{
if
(
message
.
type
===
'
warning
'
)
{
...
...
@@ -75,7 +95,7 @@ export function uniAppCssPlugin(): Plugin {
resolvedConfig
.
logger
.
warn
(
colors
.
yellow
(
msg
))
}
})
return
{
code
,
map
:
{
mappings
:
''
}
}
return
{
code
:
source
}
},
}
}
packages/uni-cli-shared/src/vite/plugins/mainJs.ts
浏览文件 @
191f250e
...
...
@@ -12,7 +12,7 @@ export function defineUniMainJsPlugin(
const
opts
=
{
resolvedConfig
:
{},
filter
(
id
)
{
return
id
===
mainJsPath
||
id
===
mainTsPath
return
id
===
mainJsPath
||
id
===
mainTsPath
||
id
===
mainUTsPath
},
}
as
UniViteFilterPluginOptions
...
...
@@ -21,6 +21,7 @@ export function defineUniMainJsPlugin(
let
mainJsPath
=
''
let
mainTsPath
=
''
let
mainUTsPath
=
''
plugin
.
configResolved
=
function
(
config
)
{
opts
.
resolvedConfig
=
config
const
mainPath
=
normalizePath
(
...
...
@@ -28,6 +29,7 @@ export function defineUniMainJsPlugin(
)
mainJsPath
=
mainPath
+
'
.js
'
mainTsPath
=
mainPath
+
'
.ts
'
mainUTsPath
=
mainPath
+
'
.uts
'
return
origConfigResolved
&&
origConfigResolved
(
config
)
}
...
...
packages/uni-cli-shared/src/vite/plugins/vitejs/plugins/css.ts
浏览文件 @
191f250e
...
...
@@ -358,18 +358,8 @@ export function cssPostPlugin(
.
map
((
id
)
=>
styles
.
get
(
id
)
||
''
)
.
join
(
'
\n
'
)
}
const
genJsCode
=
(
fileName
:
string
)
=>
{
const
res
:
string
[]
=
[]
;[...
cssChunks
.
get
(
fileName
)
!
].
forEach
((
id
)
=>
{
const
jsCode
=
styles
.
get
(
id
)
||
''
if
(
jsCode
)
{
res
.
push
(
jsCode
)
}
})
return
`[
${
res
.
join
(
'
,
'
)}
]`
}
for
(
const
filename
of
cssChunks
.
keys
())
{
const
cssCode
=
isJsCode
?
genJsCode
(
filename
)
:
genCssCode
(
filename
)
const
cssCode
=
genCssCode
(
filename
)
let
source
=
await
processChunkCSS
(
cssCode
,
{
filename
:
filename
,
inlined
:
false
,
...
...
packages/uni-cli-shared/src/vite/utils/plugin.ts
浏览文件 @
191f250e
...
...
@@ -57,3 +57,14 @@ export function removePlugins(
}
})
}
export
function
insertBeforePlugin
(
plugin
:
Plugin
,
before
:
string
,
config
:
ResolvedConfig
)
{
const
index
=
config
.
plugins
.
findIndex
((
p
)
=>
p
.
name
===
before
)
if
(
index
>
-
1
)
{
;(
config
.
plugins
as
Plugin
[]).
splice
(
index
,
0
,
plugin
)
}
}
packages/uni-mp-lark/dist/uni.compiler.js
浏览文件 @
191f250e
...
...
@@ -62,7 +62,7 @@ function transformSwiper(node) {
}
}
const
customElements
=
[
'
aweme-data
'
];
const
customElements
=
[
'
aweme-data
'
,
'
consume-card
'
];
const
projectConfigFilename
=
'
project.config.json
'
;
const
nodeTransforms
=
[
uniCliShared
.
transformRef
,
...
...
packages/uni-nvue-styler/src/parse.ts
浏览文件 @
191f250e
...
...
@@ -7,6 +7,7 @@ interface ParseOptions extends NormalizeOptions {
filename
?:
string
map
?:
boolean
ts
?:
boolean
noCode
?:
boolean
}
export
async
function
parse
(
input
:
string
,
options
:
ParseOptions
=
{})
{
...
...
@@ -19,12 +20,15 @@ export async function parse(input: string, options: ParseOptions = {}) {
root
:
null
,
messages
:
[
{
type
:
'
warning
'
,
type
:
'
error
'
,
text
:
err
.
message
,
}
as
Message
,
],
}
})
if
(
options
.
noCode
===
true
)
{
return
{
code
:
''
,
messages
}
}
const
obj
=
root
?
objectifier
(
root
)
:
{}
if
(
options
.
map
)
{
return
{
code
:
mapToInitString
(
objToMap
(
obj
),
options
.
ts
),
messages
}
...
...
packages/uni-nvue-styler/tsconfig.json
浏览文件 @
191f250e
...
...
@@ -4,7 +4,7 @@
"sourceMap"
:
false
,
"declaration"
:
true
,
"declarationDir"
:
"./dist/packages/uni-nvue-styler/src"
,
"target"
:
"es
2015
"
,
"target"
:
"es
next
"
,
"module"
:
"esnext"
,
"moduleResolution"
:
"node"
,
"allowJs"
:
false
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录