Rap*_*DDL 38
//根据文档规定,较少的单行注释应该是静默的:
单行注释在LESS中也有效,但它们是"静默的",它们不会出现在已编译的CSS输出中:
// Hi, I'm a silent comment, I won't show up in your CSS
.class { color: white }
Run Code Online (Sandbox Code Playgroud)
请参阅LESS的网站:http://lesscss.org/#-comments
-xflag在命令行上工作以输出缩小的CSS(将删除CSS注释),但无论如何,双斜杠不应出现在css上.请参阅"命令行使用"主题中的http://lesscss.org/#usage.
关于没有CLI工具的JS使用,文档说:
您可以将一些选项传递给编译器:
不幸的是,这些选项并未在任何地方指定 你必须知道代码的位置,这里是:https://github.com/less/less.js/blob/0c2c1b2ba3036c62be5fc4e6232d3c0493559764/lib/less/env.js
各种选项(在撰写本文时,来自上面链接的blob):
var parseCopyProperties = [
'paths', // option - unmodified - paths to search for imports on
'optimization', // option - optimization level (for the chunker)
'files', // list of files that have been imported, used for import-once
'contents', // map - filename to contents of all the files
'contentsIgnoredChars', // map - filename to lines at the begining of each file to ignore
'relativeUrls', // option - whether to adjust URL's to be relative
'rootpath', // option - rootpath to append to URL's
'strictImports', // option -
'insecure', // option - whether to allow imports from insecure ssl hosts
'dumpLineNumbers', // option - whether to dump line numbers
'compress', // option - whether to compress
'processImports', // option - whether to process imports. if false then imports will not be imported
'syncImport', // option - whether to import synchronously
'javascriptEnabled',// option - whether JavaScript is enabled. if undefined, defaults to true
'mime', // browser only - mime type for sheet import
'useFileCache', // browser only - whether to use the per file session cache
'currentFileInfo' // information about the current file - for error reporting and importing and making urls relative etc.
];
Run Code Online (Sandbox Code Playgroud)
和:
var evalCopyProperties = [
'silent', // whether to swallow errors and warnings
'verbose', // whether to log more activity
'compress', // whether to compress
'yuicompress', // whether to compress with the outside tool yui compressor
'ieCompat', // whether to enforce IE compatibility (IE8 data-uri)
'strictMath', // whether math has to be within parenthesis
'strictUnits', // whether units need to evaluate correctly
'cleancss', // whether to compress with clean-css
'sourceMap', // whether to output a source map
'importMultiple', // whether we are currently importing multiple copies
'urlArgs' // whether to add args into url tokens
];
Run Code Online (Sandbox Code Playgroud)
它们还通过各种使用LESS通过JS的Grunt和Gulp插件进行了记录.
所以,要回答你的问题,你不能在/**/不使用的情况下删除评论compress.所有其他事情也是如此.
2015年7月更新:在尝试-x其他答案建议的时候,我收到了这个警告:
compress选项已被弃用.我们建议您使用专用的css minifier,例如,请参阅less-plugin-clean-css.
您可以安装该插件与
npm install -g less-plugin-clean-css
Run Code Online (Sandbox Code Playgroud)
然后运行lessc与--clean-css争论.