import styles undefined
Open
Nobody has claimed this yet.
bug
- Dominant language
- JavaScript
- Stars
- 17k
- Forks
- 3.4k
- Avg merge
- 7h 42m
- Merged PRs (30d)
- 26
Description
To reproduce:
import styles from './index.less';
Current behavior:
const Home = () => {
console.log(styles) //undefined
return (
<div className={styles.main}>
</div>
);
};
{
test: /\.less$/,
use: [
NODE_ENV ? 'style-loader' : MiniCssExtractPlugin.loader,
'css-loader',
'postcss-loader',
{
loader: 'less-loader',
options: {
lessOptions: {
modules: true,
javascriptEnabled: true,
},
},
},
],
}
Expected behavior:
I hope "className= { styles.main }" can work
first, why is that?
secondly, how to fix it?
Environment information:
lessversion:4.1.3less-loaderversion:11.1.0nodejsversion:20.11.1operating system:mac
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the shown LESS import and webpack loader configuration, then inspect how the less-loader and css-loader options handle CSS modules. Done means identifying why styles is undefined and verifying or documenting a configuration that makes styles.main available with the listed versions.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, nodejs
- Domain
- frontend, web-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 28/100