feat(lessc): wire compress, source maps, URL rewriting, and math CLI flags - #4543
Conversation
The render API already supports these options; the CLI rejected them. Forward them from lessc so files can be compiled with the same surface as less.render(): - --compress / -x - --math=<mode> - --rewrite-urls[=all|local|off], --rootpath=<path>, --url-args=<args> - --source-map[=file] with the sidecar .map written next to the output and the CSS annotated with its basename; --source-map-inline embeds a data URI instead - --source-map-include-source, --source-map-rootpath, --source-map-basepath, --source-map-url for the path variants - --collapse-nesting now also accepts =native|compact Source maps already honor rootpath/basepath/url and the map's file field, so no engine change was needed — this exposes them through the CLI and covers them. Help text and the feature-status page are updated to match; the alpha CLI tests add positive coverage for every new flag plus the .map sidecar.
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Advanced Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
When --source-map=FILE writes the map to a different directory than the CSS output, the sourceMappingURL must point at it relative to the output directory (dist/app.css -> ../maps/app.map). It previously used the bare basename, which made clients request a nonexistent map next to the CSS. The same-directory common case is unchanged.
The
less.render()API already supportscompress, source maps (including therootpath/basepath/urlpath variants and inline data URIs), URL rewriting,and
mathmodes — butlesscrejected all of those flags and pointed users atthe API. This forwards them from the CLI so files can be compiled with the same
surface as the programmatic API.
New / changed flags
--compress/-x--math=<always|parens-division|parens>--rewrite-urls[=all|local|off],--rootpath=<path>,--url-args=<args>--source-map[=file]— writes the sidecar.mapnext to the output andannotates the CSS with its basename;
--source-map-inlineembeds a base64data URI instead of writing a file
--source-map-include-source,--source-map-rootpath,--source-map-basepath,--source-map-urlfor the path variants--collapse-nestingnow also accepts=native|compactThe source-map engine already honors rootpath/basepath/url and sets the map's
filefield, so no engine change was needed — this exposes and tests themthrough the CLI. When source maps are requested but CSS goes to stdout (no output
file for a sidecar), the map is inlined.
Tests / docs
test/lessc-alpha.mjsgains positive coverage for every new flag: compress,math, url-args, rootpath,
--source-map(sidecar.mapshape +filefield +sources),
--source-map-inline(data URI, no sidecar), and thebasepath/rootpath/include-source/url path variants.
V5-STATUS.mdare updated: the CLI-flags row and thesource-map path-variant note both move from "in progress" to supported.
Full
test:alpha(typecheck, build, lessc, support, source-maps, fixtures),publish-dry-run, and the packed-consumer proof pass locally.