官术网_书友最值得收藏!

  • Learning Less.js
  • Alex Libby
  • 252字
  • 2021-09-03 09:38:09

Using the command-line compiler

So far, we've used a standalone editor to compile (or Crunch!—pun intended!) our code. It has successfully produced some valid CSS for us, which can be used in a normal HTML page if desired. This works well, but might not be the preferred choice for everyone!

Instead of having to use a standalone compiler, we can achieve the same result by using the command line instead. Granted that this is a little bit more of a manual process, but it does give us the opportunity to hook in the compilation process as a command that we can run directly from most text editors.

Compiling Less files using the command line

The process to compile Less files via the command line is very easy. Start by bringing up a command prompt and changing the location to your project folder, which is the lessjs folder we created earlier. At the command prompt, type in the following command and then press Enter:

lessc variables.less variables.css

That's all that is required for a basic compilation. Less will now compile the variables.less file and save the results as variables.css in the same folder. It means that you can leave this session open in the background and rerun the command each time you want to make a change to the code.

Note

Less has a number of other options available when using lessc via the command line. To view them, type in lessc at a command prompt to display the full list.

主站蜘蛛池模板: 固安县| 姚安县| 忻州市| 包头市| 阿克苏市| 白银市| 三亚市| 宣化县| 潜江市| 蒲城县| 肇源县| 晋江市| 梧州市| 隆子县| 独山县| 昭觉县| 哈密市| 隆林| 新巴尔虎右旗| 阿巴嘎旗| 南安市| 浑源县| 行唐县| 饶河县| 北安市| 洪洞县| 景东| 斗六市| 壤塘县| 景东| 留坝县| 大冶市| 大港区| 金昌市| 丰城市| 平陆县| 于都县| 麦盖提县| 石台县| 江安县| 樟树市|