The vue project uses both sass and less

Sometimes it is necessary to use sass and less at the same time because of code needs. Now I will share some of my experience with you.

1. First, it is recommended to install Taobao mirror, if it is already installed, skip it.
Command: npm install -g cnpm --registry=https://registry.npm.taobao.org

2. If there is already sass in the project, you need to install less, execute the following code:
cnpm install less --save
cnpm install [email protected] --save
Note: The version of less installed after 2020 is all 6.0 or above, install After that, there may be an error as shown in the figure below. It is recommended that friends install a lower version of less-loader

If the higher version of less is already installed, it is recommended to reinstall the lower version after
uninstallation Command: cnpm uninstall less-loader
cnpm install [email protected] --save

3. If there is already less in the project, you need to install sass, execute the following code:
cnpm install sass-loader
cnpm install [email protected] --save
Note: sass also has high version compatibility issues, it is recommended to use a low version

4. If the modules have not been installed in the project, please execute the following command to install the lower version of sass and less first:
cnpm install less --save
cnpm install [email protected] --save
cnpm install sass-loader
cnpm install [email protected] --save

Then cnpm install
may encounter the following error at this time:

The reason is that the version of node-sass is not enough.
Solution:
Enter the command: cnpm install node-sass@latest

The experience of using sass and less on the vue project at the same time is shared here. If you like, you can give a thumbs up~
————————————————
Copyright statement: This article is a CSDN blogger The original article of "shalDream" complies with the CC 4.0 BY-SA copyright agreement. Please attach the original source link and this statement for reprinting.
Original link: https://blog.csdn.net/shalDream/article/details/106663164

Guess you like

Origin blog.csdn.net/wwf1225/article/details/114166252