Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

使用css modules引入的样式无效 #650

Closed
KellenHe opened this issue Apr 21, 2021 · 7 comments
Closed

使用css modules引入的样式无效 #650

KellenHe opened this issue Apr 21, 2021 · 7 comments
Labels
question Further information is requested

Comments

@KellenHe
Copy link

KellenHe commented Apr 21, 2021

// test.less
.test { color: red; }

// test.tsx
import styles from './test.less';
<span className={styles.test}>测试</span>

这种形式最终生成的代码,span并没有样式
<span>测试</span>

@KellenHe KellenHe added the question Further information is requested label Apr 21, 2021
@PeachScript
Copy link
Member

组件打包需要手动在 .fatherrc 配 cssModules,参考:https://github.com/umijs/father#cssmodules

@Zhou-Bill
Copy link
Contributor

Zhou-Bill commented Aug 31, 2021

如果我想用 .global.less 不走 cssModule 需要怎么配置? 开启之后好像所有都走cssModule

已解决: 只需要配置globalModulePaths 即可

 cssModules: {
    generateScopedName: '[local]___[hash:base64:5]',
    globalModulePaths: [/\.global.less$/]
  },

@dongcer
Copy link

dongcer commented Sep 7, 2021

// test.less
.test { color: red; }

// test.tsx
import styles from './test.less';
<span className={styles.test}>测试</span>

这种形式最终生成的代码,span并没有样式
<span>测试</span>

请问这个问题你解决了嘛,可以讨论下吗

@ChenYCL
Copy link

ChenYCL commented Dec 29, 2021

css-module配置后,打包es内容会发生变更么,项目中使用组件,并没做css modules的支持

@PeachScript
Copy link
Member

@ChenYCL rollup 模式不影响;如果是 babel 模式的产物 + 项目里没有 CSS Modules 配置,那么 import styles from 'xxx'styles 是没有值的

@Chasen-Zhang
Copy link

组件打包需要手动在 .fatherrc 配 cssModules,参考:https://github.com/umijs/father#cssmodules

你好,这个配置是不是有变动了,并未找到这个参数呀

@ChrisSong1994
Copy link

组件打包需要手动在 .fatherrc 配 cssModules,参考:https://github.com/umijs/father#cssmodules

你好,这个配置是不是有变动了,并未找到这个参数呀

https://d.umijs.org/guide/faq#%E4%B8%BA%E4%BB%80%E4%B9%88%E4%B8%8D%E6%94%AF%E6%8C%81-css-modules 已经明确不支持了

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

7 participants