dev开发中刷新浏览器会造成global.less中样式丢失,这个时候保存一下global.less编译一次才能生效。
dev开发中刷新浏览器会造成global.less中样式丢失
怎么重现?原因应该不是刷新浏览器,刷新浏览器不会修改 dev 生成的样式文件的。
因为首页的index.css变成了umi.css
我们出现的情况是,在主页面global丢失,其他页面正常。
主页面加载了 index.css
其他页面加载umi.css

public/index.html 不需要,删了吧。
@sorrycc 准确说global.less的权重降低了,导致没有覆盖ant的样式。
在ant design pro里面就可以重现,修改models引起的刷新也会导致样式权重降低.
对,权重降低也是一个问题,好多css失效
为什么我把global.css改成global.less会报错?
求快速修复这个bug
@sorrycc 这个问题修了嘛
@sorrycc 准确说global.less的权重降低了,导致没有覆盖ant的样式。
在ant design pro里面就可以重现,修改models引起的刷新也会导致样式权重降低.
global.less 中样式用来提供默认样式的话权重应该就是最低吧,如果要覆盖样式的话用 config.theme 或者局部组件覆盖会不会更清晰一点。
@dilidili global的权重应该要大于antd自带样式的权重。
@dilidili 我也认同 @xiaohuoni 的看法: 'global的权重应该要大于antd自带样式的权重。'
css类同名的情况下,global的权重应该要大于antd自带样式的权重,小于page样式的权重。
node_module里面的样式,打成一个css文件,如a.css。然后项目中的样式打成一个b.css.这样global.css里面的内容,应该是放在b.css头部。然后页面上加载样式文件的顺序是a.css b.css。
Any updates on that? Maybe this should be as additional setting in .umirc?
Something like preferGlobalCss: true
And make this false (as in current version) by default to make backward compatibility.
The weight of @dilidili global should be greater than the weight of antd's own style.
I agree. There are some problems with overriding, for example, styles of 'boostrasp-css-only' third-party library or 'antd' or something else.
@xiaohuoni @iceberg211 https://github.com/umijs/umi/issues/1649#issuecomment-448170459 这方案有效吗?
@sorrycc 和#root 包裹应该是一样的吧,按需加载,还是有问题的吧,还是说,我没理解这个方案?
我理解的是,加了 root 之后,优先级不是最高了吗?那就算先载入不也应该没有问题?
现在的表现是,加了root可以处理优先级问题,但是按需加载,好像会重新引入antd的样式,最终生效的是antd的样式
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
emmmmmm, 我这里遇到了 global.less 不生效的问题... 审查元素, 并没有 global 里面的 全局样式... 有自查的建议吗... ?
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
@sorrycc 这个问题似乎依然还是存在?
主要是样式优先级问题
Most helpful comment
@dilidili global的权重应该要大于antd自带样式的权重。