Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to solve the problem that less doesn't work in react

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)05/31 Report--

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.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report