用命令行编译Less源文件需要先安装node.js,官方下载地址:http://nodejs.org/

使用npm包管理工具安装Less编译器

npm install less -g

参数-g 是安装到全部环境中的指令,如果只想安装特定版本,可使用如下命令

npm install less@1.6.2 -g

Less编译器用法:

Usage: lessc [option option=parameter ...] <source> [destination]

示例:

E:\Dev\Dev2015\less compile dir>lessc bootstrap.less bootstrap.css

这样就会生产.css文件

压缩输出文件大小

lessc -x bootstrap.less bootstrap.css

通过使用-x参数,来压缩输出文件的大小,下面是压缩前后的文件大小

-x 压缩主要是删除多余空白实现的

获取帮助

lessc --help

lessc -h

其他常用命令

输出导文件的依赖关系列表

 -M, --depends            Outputs a makefile import dependency list to stdout.

禁用颜色

--no-color               Disables colorized output.

禁用IE兼容性检查

--no-ie-compat           Disables IE compatibility checks.

禁用JavaScript

--no-js                  Disables JavaScript in less files

语法检查

-l, --lint               Syntax check only (lint).

忽略警告信息

-s, --silent             Suppresses output of error messages.

 --strict-imports         Forces evaluation of imports.

允许导入不安全的https主机

 --insecure               Allows imports from insecure https hosts.

插件的使用

--plugin=PLUGIN=OPTIONS  Loads a plugin. You can also omit the --plugin= if the plugin beginsless-plugin. E.g. the clean css plugin is called less-plugin-clean-cssonce installed (npm install less-plugin-clean-css), use either with--plugin=less-plugin-clean-css or just --clean-cssspecify options afterwards e.g. --plugin=less-plugin-clean-css="advanced"or --clean-css="advanced"

安装插件

PS E:\Dev\Dev2015\less compile dir> npm install less-plugin-clean-css
less-plugin-clean-css@1.5.0 node_modules\less-plugin-clean-css
└── clean-css@3.1.2 (commander@2.6.0, source-map@0.1.43)
PS E:\Dev\Dev2015\less compile dir>

使用less-plugin-clean-css插件进行输出压缩

lessc --plugin=less-plugin-clean-css .\bootstrap.less bootstrap.css

查看版本

 -v, --version            Prints version number and exit.

 --source-map[=FILENAME]  Outputs a v3 sourcemap to the filename (or output filename.map).--source-map-rootpath=X  Adds this path onto the sourcemap filename and less file paths.--source-map-basepath=X  Sets sourcemap base path, defaults to current working directory.--source-map-less-inline Puts the less files into the map instead of referencing them.--source-map-map-inline  Puts the map (and any less files) as a base64 data uri into the output css file.--source-map-url=URL     Sets a custom URL to map file, for sourceMappingURL commentin generated CSS file.-rp, --rootpath=URL      Sets rootpath for url rewriting in relative imports and urlsWorks with or without the relative-urls option.-ru, --relative-urls     Re-writes relative urls to the base less file.-sm=on|off               Turns on or off strict math, where in strict mode, math.--strict-math=on|off     Requires brackets. This option may default to on and thenbe removed in the future.-su=on|off               Allows mixed units, e.g. 1px+1em or 1px*1px which have units--strict-units=on|off    that cannot be represented.--global-var='VAR=VALUE' Defines a variable that can be referenced by the file.--modify-var='VAR=VALUE' Modifies a variable already declared in the file.--url-args='QUERYSTRING' Adds params into url tokens (e.g. 42, cb=42 or 'a=1&b=2')--plugin=PLUGIN=OPTIONS  Loads a plugin. You can also omit the --plugin= if the plugin beginsless-plugin. E.g. the clean css plugin is called less-plugin-clean-cssonce installed (npm install less-plugin-clean-css), use either with--plugin=less-plugin-clean-css or just --clean-cssspecify options afterwards e.g. --plugin=less-plugin-clean-css="advanced"or --clean-css="advanced"------------------------- Deprecated ------------------line-numbers=TYPE      Outputs filename and line numbers.TYPE can be either 'comments', which will outputthe debug info within comments, 'mediaquery'that will output the information within a fakemedia query which is compatible with the SASSformat, and 'all' which will do both.--verbose                Be verbose.-x, --compress           Compresses output by removing some whitespaces.We recommend you use a dedicated minifer like less-plugin-clean-css

转载于:https://www.cnblogs.com/tao-zi/p/4310184.html

使用命令行编译Less源文件相关推荐

  1. java打包dex_Android 命令行编译、打包生成apk文件

    一.搭建搭建环境 1. 安装JDK 和 Android SDK 2. 配置环境变量 D:\android-sdk-windows\tools C:\Program Files\Java\jdk1.6. ...

  2. Java 命令行编译项目

    如果是用Exlipse, 第三方的包可以放在eclipse文件夹的jre包的lib文件夹中! (初学者的一些总结-高手们勿喷哈-) 原因: 以前一直用Eclispe编程环境运行Java.非常舒服,就像 ...

  3. Java按包编译jar_java用命令行编译运行时带有包和使用外部jar包的情况

    命令行编译运行Java程序时,加载指定目录中的Jar包: 解决方案一: 编译:javac -Djava.ext.dirs=./lib Test.java  或 javac -Djava.ext.dir ...

  4. Java script生成apk_Android 命令行编译、打包生成apk文件

    一.搭建搭建环境 1. 安装JDK 和 Android SDK 2. 配置环境变量 D:\android-sdk-windows\tools C:\Program Files\Java\jdk1.6. ...

  5. 命令行编译运行CSharp文件

    命令行编译运行CSharp文件 找到csc.exe所在的路径.如我本机上为"C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727" 在环境变量 ...

  6. Windows使用MSVC,命令行编译,链接64位dll,Python调用

    文章目录 代码 编译 链接 Python调用 前一篇博客: Windows下使用Visual Studio自带的MSVC,命令行编译C/C++程序 代码 mylib.h代码如下: #ifndef MY ...

  7. python 基础命令-Python unittest第一篇:基础入门+命令行编译

    unittest单元测试框架最初受JUnit启发,与其他语言的主要单元测试框架具有相似的风格. 它支持测试自动化,支持开启或关闭某个测试,支持结合测试.另外它可以生成各个单元测试的报告.为了实现以上功 ...

  8. 命令行编译 WRK ,windbg 调试

    一.准备工作 本文记录如何用命令行编译WRK内核,下面列出需要准备的东西: win2k3 sp1 虚拟机环境 WRK v1.2源码 两个需要用到的dll:msvcr71.dll ,msvcp71.dl ...

  9. VC6命令行编译工程方法

    VC6命令行编译工程方法 昨天下载一个界面库wxWidgets,编译里面的库很痛苦,有好几个工程,我的在一边等待,痛苦!!于是上网找到命令行编译的方法,可以写一个批处理文件,呵呵,想起以前经理编译工程 ...

最新文章

  1. Response 和 Request
  2. linux服务器在线人数,servlet监听器实现在线人数统计源码实例
  3. 高性能jdbc封装工具 Apache Commons DbUtils 1.6(转载)
  4. python 运行结果保存_『如何将python运行结果保存成txt,万分感谢呐』python txt教程...
  5. Spring EL hello world实例
  6. bufg和bufgp_如何将自己写的verilog模块封装成IP核(一)
  7. python怎么让输出居中_python格式化输出字符串居中
  8. [置顶] Ubuntu 12.04中文输入法的安装
  9. [LUOGU] P1111 修复公路
  10. sudo chown -R nobody:nogroup clear
  11. 达梦安装与基本使用【进阶】
  12. OMNeT 例程 Tictoc12 学习笔记
  13. 计算机系统关机后自动重启,深度技术win7系统电脑关机后又自动开机如何解决【图文】...
  14. threejs - uv 映射 简要
  15. 在VM安装最新版Linux镜像
  16. uniapp项目H5端横屏问题-样式错乱+字体大小+video
  17. C# 日期插入access数据库
  18. VUE echarts绘制省级/市级地图自动轮循tooltip
  19. Pycharm专业版下载、安装、与Anaconda配置、中文化及字体设置、Cracking(自行翻译)方法
  20. echart横轴文字显示省略号_Echarts X轴内容过长自动隐藏,鼠标移动上去显示全部名称方法...

热门文章

  1. 【转】通过IRQL看NT内核
  2. 成功加入微软GDI计划
  3. iptables高级应用实例
  4. 转子接地保护原理_发电机转子一点接地:保护原理、整定方法、动作后果
  5. python0x80070643_Win10提示Python 0x80070643安装时发生严重错误
  6. mysql trim 索引_mysql 强大的trim() 函数
  7. 计算机可用内存分配失败,你们都被忽悠了! 其实可用内存大才有用
  8. android必看java_Android开发工程师必看笔试题:Java基础选择题(一)
  9. androidentity什么用_Android multipartentity的用法
  10. 服务器上显示存储脱机,已解决: 如何清除windows2008服务器磁盘脱机显示 - Dell Community...