Skip to content

Migrate Less compilation to ipl\Web\Less#5492

Open
lippserd wants to merge 4 commits intomainfrom
less
Open

Migrate Less compilation to ipl\Web\Less#5492
lippserd wants to merge 4 commits intomainfrom
less

Conversation

@lippserd
Copy link
Copy Markdown
Member

@lippserd lippserd commented Apr 9, 2026

Because the in-tree Less visitor requires wikimedia/less.php, that dependency has to live in icinga-php-thirdparty. icinga-php-library already carries Less-related code with the same dependency, so this PR consolidates everything into icinga-php-library and removes the duplicate in-tree implementation.

  • Remove the in-tree Icinga\Less\ visitor layer in favor of the shared ipl\Web\Less library, which maintains modernized equivalent CSS var replacement and light-mode functionality.
  • Strip unused variable-export support from LessCompiler — the feature was never used by any our modules or community modules.
  • Update LessCompiler to delegate to ipl\Web\Less, assembling sources via @import (less) directives; pass the $minify flag directly to render() instead of via a separate compress() call.
  • Modernize LessCompiler with PHP type declarations, short array syntax, and tightened PHPDoc.

For testing, use 7da4917 as the baseline, which adapts light mode rule evaluation order to match the new visitor.

Here is my test summary:

The stylesheets are nearly identical. All but one difference are cosmetic normalizations introduced by the new version of the wikimedia Less parser:

Category Example
Decimal leading zero .5em0.5em
Hex color shortening #dddddd#ddd
Color name normalization #ffffffwhite, #ff0000red
transparentrgba(0,0,0,0) fallback in var() expressions
Trailing .0 stripped 2.0em2em, 1.01
calc() kept as fractions calc(14.28571429%)calc(100% / 7)
Font shorthand explicit line-height 1em1em/1

There is one functional difference: the light-mode background color gains an extra level of indirection via a new CSS var call (because it uses @light-body-bg-color):

-  --body-bg-color: #f5f9fa;
+  --body-bg-color: var(--light-body-bg-color, #f5f9fa);

The new CSS var replacement visitor from ipl\Web runs independently from the light mode call visitor, and therefore also adds var overrides to such detached rulesets. Everything else is normalization noise.

closes #5457
requires Icinga/icinga-php-thirdparty#115
requires Icinga/ipl-web#365

This is a preparation for using the new Less utils from `ipl\Web` to simplify
the comparison of the old and new stylesheets.
This reverts commit 7c58b3c.

Remove variable exports as they were never used in our modules or community
modules, and using this feature is discouraged.
Replace the in-tree `Icinga\Less\` visitor layer with its equivalents
from `ipl\Web\Less`, where the same color-variable and light-mode
functionality is maintained as a shared library.

`LessCompiler` is updated to delegate to `WikimediaLessCompiler`,
assembling source via `@import (less)` directives and accepting a
`$minify` flag directly on `render()` rather than through a separate
`compress()` call.
Add missing PHP type declarations to properties and methods, replace long-form
`array()` syntax with short `[]` syntax, tighten PHPDoc comments, and correct
"LESS" to "Less".
@lippserd lippserd changed the title Use Less utils from ipl-web Migrate Less compilation to ipl\Web\Less Apr 10, 2026
@lippserd lippserd added this to the 2.14.0 milestone Apr 10, 2026
@lippserd lippserd marked this pull request as ready for review April 10, 2026 14:40
@lippserd lippserd requested a review from nilmerg April 10, 2026 14:40
);

if (in_array($path, $special)) {
putenv('ICINGAWEB_ENVIRONMENT=production');
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please note that this must be removed before merging the PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant