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

less object is empty in CRA project #421

Closed
Inuyashaaaaa opened this issue Jun 10, 2021 · 1 comment
Closed

less object is empty in CRA project #421

Inuyashaaaaa opened this issue Jun 10, 2021 · 1 comment

Comments

@Inuyashaaaaa
Copy link

Inuyashaaaaa commented Jun 10, 2021

  • Operating System: window10
  • Node Version: v14.4.0
  • NPM Version: 6.14.5
  • webpack Version: 4.44.2
  • less-loader Version: 5.0.0

Expected Behavior

less object is not empty and can be used for react className to change antd styles

Actual Behavior

less object is empty and can not change antd styles

Code

// src/pages/Login/index.less
:global {
  .ant-input-affix-wrapper {
    height: 50px;
  }
}
// src/pages/Login/index.jsx
import styles from "./index.less";
console.log(styles); // {}

const Login = () => {

  return (
    <div className={styles.scope}>
       // some antd components
    </div>
  );
}

How Do We Reproduce?

clone https://github.com/Inuyashaaaaa/lessErrorRespository and find src/pages/Login/index.less and src/pages/Login/index.jsx

the same question in stack overflow is https://stackoverflow.com/questions/51685999/less-object-is-empty-in-react-webpack
but no body answer

@alexander-akait
Copy link
Member

Problem here import styles from "./index.less";, change it on import styles from "./index.module.less"; and rename index.less to index.module.less, CRA uses module prefix for CSS modules

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

No branches or pull requests

2 participants