缠丝猫 发表于 2024-7-16 21:26:38

重新安装依赖后,sass报警告Sass‘s behavior for declarations that appea

本日拉代替码,重新实验pnpm i安装依赖后。发现终端出来了一堆sass的警告,
    Deprecation Warning: Sass’s behavior for declarations that appear
after nested rules will be changing to match the behavior specified by
CSS in an upcoming version. To keep the existing behavior, move the
declaration above the nested rule. To opt into the new behavior, wrap
the declaration in & {}.
More info: https://sass-lang.com/d/mixed-decls
┌──> node_modules\element-plus\theme-chalk\src\mixins_button.scss
159│ padding: $padding-vertical $padding-horizontal; │
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ declaration ╵
┌──> node_modules\element-plus\theme-chalk\src\button.scss 71 │ ┌ &


[*]& { 72 │ │ margin-left: 12px; 73 │ │ } │ └─── nested rule
原因

根据给的错误信息,在sass官网可以看到说明。sass新版本有破坏性变更。
https://sass-lang.com/d/mixed-decls
https://i-blog.csdnimg.cn/direct/9ac27de978834737bc603f7a204157d9.png
简单来说就是,sass为了迎合css的行为,对原来的嵌套规则了做了限定。但是许多组件库都是旧的写法。包罗我们项目常用的elemnet-plus。可以在错误信息看到,许多指向的都是element的组件样式。
相关issues讨论 https://github.com/element-plus/element-plus/issues/17487
办理方法

知道原因后,我认为如许的变更覆盖面太广,许多组件库不可能第一时间做出更新,何况还有本身写的代码还有不再维护的组件库。以是要想办理这个问题,最好的办法就是降低sass的版本。
版本是在1.77.7开始的。 以是可以固定sass的版本在1.77.6之前。
https://i-blog.csdnimg.cn/direct/0bcb0a0aa8f94a3189c404d7d73ffc72.png

免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。
页: [1]
查看完整版本: 重新安装依赖后,sass报警告Sass‘s behavior for declarations that appea