Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
D-GSQ
uni-app
提交
eb824626
U
uni-app
项目概览
D-GSQ
/
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,发现更多精彩内容 >>
提交
eb824626
编写于
8月 05, 2022
作者:
Q
qiang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix: postcss-uniapp-plugin support postcss8
上级
97eb491c
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
65 addition
and
33 deletion
+65
-33
packages/vue-cli-plugin-uni/package.json
packages/vue-cli-plugin-uni/package.json
+3
-1
packages/vue-cli-plugin-uni/packages/postcss/index.js
packages/vue-cli-plugin-uni/packages/postcss/index.js
+17
-2
packages/vue-cli-plugin-uni/packages/postcss/index.v3.js
packages/vue-cli-plugin-uni/packages/postcss/index.v3.js
+45
-30
未找到文件。
packages/vue-cli-plugin-uni/package.json
浏览文件 @
eb824626
...
...
@@ -29,7 +29,6 @@
"mkdirp"
:
"^0.5.1"
,
"module-alias"
:
"^2.1.0"
,
"neo-async"
:
"^2.6.1"
,
"postcss"
:
"^7.0.7"
,
"postcss-import"
:
"^12.0.1"
,
"postcss-selector-parser"
:
"^5.0.0"
,
"postcss-value-parser"
:
"^3.3.1"
,
...
...
@@ -39,5 +38,8 @@
"wrap-loader"
:
"^0.2.0"
,
"xregexp"
:
"4.0.0"
},
"peerDependencies"
:
{
"postcss"
:
">=7"
},
"gitHead"
:
"9e2d0f8e244724fcd64880316c57d837d1778cf8"
}
packages/vue-cli-plugin-uni/packages/postcss/index.js
浏览文件 @
eb824626
...
...
@@ -156,7 +156,7 @@ if (process.env.UNI_USING_V3) {
* 转换 upx
* 转换 px
*/
module
.
exports
=
postcss
.
plugin
(
'
postcss-uniapp-plugin
'
,
function
(
opts
)
{
const
fn
=
function
(
opts
)
{
opts
=
{
...
defaultOpts
,
...
opts
...
...
@@ -265,5 +265,20 @@ if (process.env.UNI_USING_V3) {
})
}
}
})
}
const
version
=
Number
(
require
(
'
postcss/package.json
'
).
version
.
split
(
'
.
'
)[
0
])
if
(
version
<
8
)
{
module
.
exports
=
postcss
.
plugin
(
'
postcss-uniapp-plugin
'
,
fn
)
}
else
{
module
.
exports
=
function
(
opts
)
{
return
{
postcssPlugin
:
'
postcss-uniapp-plugin
'
,
Once
:
fn
(
opts
)
}
}
module
.
exports
.
postcss
=
true
}
}
packages/vue-cli-plugin-uni/packages/postcss/index.v3.js
浏览文件 @
eb824626
const
postcss
=
require
(
'
postcss
'
)
const
selectorParser
=
require
(
'
postcss-selector-parser
'
)
const
TAGS
=
Object
.
keys
(
require
(
'
@dcloudio/uni-cli-shared
'
).
tags
)
...
...
@@ -14,34 +13,50 @@ const isInsideKeyframes = function (rule) {
let
rewriteUrl
module
.
exports
=
postcss
.
plugin
(
'
postcss-uniapp-plugin
'
,
function
(
opts
)
{
return
function
(
root
,
result
)
{
if
(
!
rewriteUrl
)
{
rewriteUrl
=
require
(
'
@dcloudio/uni-cli-shared/lib/url-loader
'
).
rewriteUrl
}
rewriteUrl
(
root
)
root
.
walkRules
(
rule
=>
{
// Transform each rule here
if
(
!
isInsideKeyframes
(
rule
))
{
// rule.selectors == comma seperated selectors
// a, b.c {} => ["a", "b.c"]
rule
.
selectors
=
rule
.
selectors
.
map
(
complexSelector
=>
// complexSelector => simpleSelectors
// "a.b#c" => ["a", ".b", "#c"]
transformSelector
(
complexSelector
,
simpleSelectors
=>
{
// only process type selector, leave alone class & id selectors
return
simpleSelectors
.
walkTags
(
tag
=>
{
if
(
tag
.
value
===
'
page
'
)
{
tag
.
value
=
'
body
'
}
else
if
(
~
TAGS
.
indexOf
(
tag
.
value
)
&&
tag
.
value
.
substring
(
0
,
4
)
!==
'
uni-
'
)
{
tag
.
value
=
'
uni-
'
+
tag
.
value
}
})
function
once
(
root
)
{
if
(
!
rewriteUrl
)
{
rewriteUrl
=
require
(
'
@dcloudio/uni-cli-shared/lib/url-loader
'
).
rewriteUrl
}
rewriteUrl
(
root
)
root
.
walkRules
(
rule
=>
{
// Transform each rule here
if
(
!
isInsideKeyframes
(
rule
))
{
// rule.selectors == comma seperated selectors
// a, b.c {} => ["a", "b.c"]
rule
.
selectors
=
rule
.
selectors
.
map
(
complexSelector
=>
// complexSelector => simpleSelectors
// "a.b#c" => ["a", ".b", "#c"]
transformSelector
(
complexSelector
,
simpleSelectors
=>
{
// only process type selector, leave alone class & id selectors
return
simpleSelectors
.
walkTags
(
tag
=>
{
if
(
tag
.
value
===
'
page
'
)
{
tag
.
value
=
'
body
'
}
else
if
(
~
TAGS
.
indexOf
(
tag
.
value
)
&&
tag
.
value
.
substring
(
0
,
4
)
!==
'
uni-
'
)
{
tag
.
value
=
'
uni-
'
+
tag
.
value
}
})
)
}
})
})
)
}
})
}
const
version
=
Number
(
require
(
'
postcss/package.json
'
).
version
.
split
(
'
.
'
)[
0
])
if
(
version
<
8
)
{
const
postcss
=
require
(
'
postcss
'
)
module
.
exports
=
postcss
.
plugin
(
'
postcss-uniapp-plugin
'
,
function
(
opts
)
{
return
once
})
}
else
{
module
.
exports
=
function
(
opts
)
{
return
{
postcssPlugin
:
'
postcss-uniapp-plugin
'
,
Once
:
once
}
}
})
module
.
exports
.
postcss
=
true
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录