How to solve the problem that less doesn't work in react
Today, Xiaobian will share with you the relevant knowledge points on how to solve the problem of less does not work in react. The content is detailed and the logic is clear. I believe most people still know too much about this knowledge, so share this article for your reference. I hope you will gain something after reading this article. Let's find out together.
Solution: 1. Use "npm install -g less" to install plug-in, convert less to css, and use "lessc less file css file" command in the converted directory;2. Modify the contents of "lessOptions" under the "node_modules" directory.
This tutorial will operate on Windows 10, React17.0.1, Dell G3 PC.
What if less in reaction doesn't work?
Method 1: Convert less to CSS by installing plug-ins
npm install -g less
Then go to the directory you want to convert (e.g. cd .\ src\pages\login\), enter the command:
Example: lessc login.less login.css
This method can only solve a file problem temporarily
Method 2: Go to the node_modules directory and find react-scripts -> config -> webpack.config.js to modify the contents:
The above is all the content of this article, thank you for reading! I believe everyone has a great harvest after reading this article. Xiaobian will update different knowledge for everyone every day. If you want to learn more knowledge, please pay attention to the industry information channel.