没有不值得去解决的问题,也没有不值得去学习的技术!

Convert Less to CSS With the Less Compiler in PhpStorm

Create a new style.less file, add some content, and automatically compile to generate a style.css file

1. Use NPM to install the Less compiler and check the NPM version, as shown in Figure 1
npm -V

Use NPM to install the Less compiler and check the NPM version
Figure 1

2. To globally install the Less compiler and run NPM in PhpStorm, select File to open Settings, as shown in Figure 2

Globally install the Less compiler, run NPM in PhpStorm, select File, and open Settings
Figure 2

3. Click Node.js and NPM under “Languages & Frameworks”. On the opened Node.js and NPM page, the Packages area displays all Node.js related packages currently installed on your computer, whether globally or at the project level. less is installed, as shown in Figure 3

Click Node.js and NPM under "Languages & Frameworks". On the opened Node.js and NPM page, the Packages area displays all Node.js related packages currently installed on your computer, whether globally or at the project level. less is installed
Figure 3

4. Create a File Watcher by selecting File to open Settings, as shown in Figure 2

Globally install the Less compiler, run NPM in PhpStorm, select File, and open Settings
Figure 2

5. Click “File Watchers” under the “Tools” node. The opened File Watchers page displays a list of File Watchers already configured in the project, as shown in Figure 4

Click "File Watchers" under the "Tools" node. The opened File Watchers page displays a list of File Watchers already configured in the project.
Figure 4

6. Repeat step 3 and find that less is installed at the project level rather than globally, as shown in Figure 5

Repeat step 3 and find that less is installed at the project level rather than globally
Figure 5

7. Run the installation from the command line in global mode. Type the following command at the command prompt using the Taobao NPM mirror, as shown in Figure 6

cnpm install -g less

Run the installation from the command line in global mode. Type the following command at the command prompt using the Taobao NPM mirror
Figure 6

8. Add this folder: C:\Users\Administrator\AppData\Roaming\npm\node_modules\less to the PATH variable, as shown in Figure 7

Add this folder: C:\Users\Administrator\AppData\Roaming\npm\node_modules\less to the PATH variable
Figure 7

9. Repeat step 5 and specify the program folder: C:\Users\Administrator\AppData\Roaming\npm\lessc.cmd, as shown in Figure 8

Repeat step 5 and specify the program folder: C:\Users\Administrator\AppData\Roaming\npm\lessc.cmd
Figure 8

10. Create a new style.less file, add some content, and it will automatically compile to generate a style.css file, as shown in Figure 9

Create a new style.less file, add some content, and automatically compile to generate a style.css file
Figure 9

关于作者 · 持续学习与技术实践

我是一名拥有 15 年以上开发经验的技术从业者,自 2013 年起持续运营个人技术博客,记录工作与个人项目中遇到的真实问题,以及解决问题过程中的探索、实践和思考。

除了技术写作,我也在持续开发和维护自己的独立项目,探索新技术和新工具在实际场景中的应用。我始终相信,没有不值得去解决的问题,也没有不值得去学习的技术。

如果这篇文章对你有所帮助,欢迎浏览博客中的其他文章,也欢迎交流技术经验与想法。

关于我  ·  GitHub  ·  邮件联系