The introduction of less by react has no effect.

I configure the introduction of less in create-react-app by installing react-app-rewire-less in the way that the official website of antd is installed.

there is no problem with className = "header" if you directly import". / App.less", and then use it.

but less will have no effect if className= {styles.header} is used in import styles". / App.less",. Excuse me, what is the reason for this?

Mar.22,2021

Let me publish the correct answer: to use css-module, you need to name the css file fileName.module.less, and then you can introduce it into the component and use it normally, as follows:

Note that by default the suffix must be .module.less to be written as css-module

for example, the following code:
import React, {Component} from "react";
import {Button} from "antd";
import styles1 from ". / index.module.less";

class Hello extends Component {
render () {

return (
  <div className={styles1.main}>
    hello
    <div className={styles1.text}>world</div>
    <Button type="primary"></Button>
    <div className="text1">heihei</div>
  </div>
);

}
}

export default Hello;

this will take effect


Is

import styles'. / App.less', missing a from import styles from'. / App.less'

the second thing is to see if you start module: true, which is the so-called modularization! The specific need to see your configuration to ask the price! It will be available as soon as you move online


in webpack, set disableCSSModules to false


how to solve the problem. According to the configuration settings, running the less file has no effect

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3de90-2bc24.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3de90-2bc24.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?