关于没有 CLI 工具的 JS 使用,docs say:
您可以将一些选项传递给编译器:
不幸的是,这些选项没有在任何地方指定。你必须知道在哪里看代码,这里是: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.
];
和:
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
];
通过 JS 使用 LESS 的各种 Grunt 和 Gulp 插件也记录了它们。
因此,要回答您的问题,您不能在不使用 compress 的情况下真正去除 /**/ cmets。它也可以处理所有其他类型的事情。