Compare commits

...

3 Commits

Author SHA1 Message Date
Sebastian Fischer
55ddc3b5e2 Merge branch 'release/2.3.1' 2025-08-17 17:28:10 +02:00
6182935a22 Improve css unique 2025-08-17 17:26:24 +02:00
Sebastian Fischer
2d5729ded6 Merge tag '2.3.0' into develop
Release styles merging
2025-04-26 20:04:25 +02:00

View File

@ -26,6 +26,7 @@ class Tailwindcss4Merger
$atLayerComponents = $this->getLayerComponents($styles); $atLayerComponents = $this->getLayerComponents($styles);
$atProperty = $this->getProperties($styles); $atProperty = $this->getProperties($styles);
$atLayerProperties = $this->getLayerProperties($styles); $atLayerProperties = $this->getLayerProperties($styles);
$unlayered = $this->getUnlayered($styles);
return implode(chr(10), [ return implode(chr(10), [
$atLayerOrder, $atLayerOrder,
$atLayerBase, $atLayerBase,
@ -34,6 +35,7 @@ class Tailwindcss4Merger
$atLayerComponents, $atLayerComponents,
$atProperty, $atProperty,
$atLayerProperties, $atLayerProperties,
$unlayered,
]); ]);
} }
@ -122,7 +124,8 @@ class Tailwindcss4Merger
{ {
$matches = $this->getLayerByName($styles, 'properties'); $matches = $this->getLayerByName($styles, 'properties');
$properties = [ $properties = [
' @supports ((-webkit-hyphens: none) and (not (margin-trim: inline))) or ((-moz-orient: inline) and (not (color:rgb(from red r g b)))) { ' @supports ((-webkit-hyphens: none) and (not (margin-trim: inline))) or ((-moz-orient: inline)'
. ' and (not (color:rgb(from red r g b)))) {
*, ::before, ::after, ::backdrop {' *, ::before, ::after, ::backdrop {'
]; ];
foreach ($matches as $match) { foreach ($matches as $match) {
@ -144,4 +147,11 @@ class Tailwindcss4Merger
{ {
return '@layer ' . $name . " {\n" . implode("\n", $styles) . "\n}"; return '@layer ' . $name . " {\n" . implode("\n", $styles) . "\n}";
} }
protected function getUnlayered(string $styles): string
{
$unlayered = preg_replace('/(?<layer>@layer[^;{]+;)/i', '', $styles, -1);
$unlayered = preg_replace('/@layer[^{;]+\{.+?(?=\n})\n}/s', '', $unlayered, -1);
return preg_replace('/(?<property>@property[^{]+\{[^}]+})/i', '', $unlayered, -1);
}
} }