From 17d8a62b857e6f094aca798799b8a4ad6d061242 Mon Sep 17 00:00:00 2001 From: Hugo Alliaume Date: Wed, 20 May 2026 21:26:20 +0200 Subject: [PATCH] Do not remove document tags from from minified HTML, some `og:image` improvements Related to our LinkedIn post preview issue... The `og:image` can't be displayed because of missing `` tags. Opened https://github.com/sensiolabs/minify-bundle/pull/41. --- composer.json | 8 +++- composer.lock | 39 ++++++++++++------- config/reference.php | 1 + .../FilesystemStaticPageDumper.php | 7 +++- templates/pages/blog/article.html.twig | 1 + templates/pages/blog/index.html.twig | 3 ++ templates/pages/team/index.html.twig | 3 ++ templates/pages/website/home.html.twig | 3 ++ .../pages/website/legal_notices.html.twig | 3 ++ 9 files changed, 52 insertions(+), 16 deletions(-) diff --git a/composer.json b/composer.json index ebadaa9..70e10e3 100644 --- a/composer.json +++ b/composer.json @@ -12,7 +12,7 @@ "league/commonmark": "^2.8.2", "phpdocumentor/reflection-docblock": "^5.6.7", "phpstan/phpdoc-parser": "^2.3.2", - "sensiolabs/minify-bundle": "^1.2.0", + "sensiolabs/minify-bundle": "dev-feat/html-support as 1.3.0", "symfony/asset": "8.0.*", "symfony/asset-mapper": "8.0.*", "symfony/cache": "8.0.*", @@ -104,6 +104,12 @@ "docker": true } }, + "repositories": [ + { + "type": "vcs", + "url": "https://github.com/bakslashHQ/minify-bundle" + } + ], "require-dev": { "kocal/biome-js-bundle": "^2.1.2", "phpstan/phpstan": "^2.1.46", diff --git a/composer.lock b/composer.lock index 0871ab0..f989185 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "602c28fa26eca4c6edaaccd0f79ac7fc", + "content-hash": "5f119dd1c63b2f6459060d12c36a4bc8", "packages": [ { "name": "composer/semver", @@ -1249,16 +1249,16 @@ }, { "name": "sensiolabs/minify-bundle", - "version": "v1.2.0", + "version": "dev-feat/html-support", "source": { "type": "git", - "url": "https://github.com/sensiolabs/minify-bundle.git", - "reference": "cf6462fbbd7883367c6ee1f02424e93a3df79384" + "url": "https://github.com/bakslashHQ/minify-bundle.git", + "reference": "d1f26e79afea0595ff7ef95d97fbff00a528134f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sensiolabs/minify-bundle/zipball/cf6462fbbd7883367c6ee1f02424e93a3df79384", - "reference": "cf6462fbbd7883367c6ee1f02424e93a3df79384", + "url": "https://api.github.com/repos/bakslashHQ/minify-bundle/zipball/d1f26e79afea0595ff7ef95d97fbff00a528134f", + "reference": "d1f26e79afea0595ff7ef95d97fbff00a528134f", "shasum": "" }, "require": { @@ -1280,8 +1280,8 @@ "type": "symfony-bundle", "extra": { "thanks": { - "url": "https://github.com/tdewolff/minify", - "name": "tdewolff/minify" + "name": "tdewolff/minify", + "url": "https://github.com/tdewolff/minify" } }, "autoload": { @@ -1289,7 +1289,11 @@ "Sensiolabs\\MinifyBundle\\": "src/" } }, - "notification-url": "https://packagist.org/downloads/", + "autoload-dev": { + "psr-4": { + "Sensiolabs\\MinifyBundle\\Tests\\": "tests/" + } + }, "license": [ "MIT" ], @@ -1306,21 +1310,20 @@ "description": "Assets Minifier (CSS, JS) for Symfony & Minify integration in Asset Mapper", "homepage": "https://github.com/sensiolabs/minify-bundle", "keywords": [ - "JS", "asset-mapper", "assets", "compress", "css", + "js", "minifier", "minify", "symfony", "uglify" ], "support": { - "issues": "https://github.com/sensiolabs/minify-bundle/issues", - "source": "https://github.com/sensiolabs/minify-bundle/tree/v1.2.0" + "source": "https://github.com/bakslashHQ/minify-bundle/tree/feat/html-support" }, - "time": "2025-08-19T18:45:10+00:00" + "time": "2026-05-20T19:18:46+00:00" }, { "name": "symfony/asset", @@ -9835,9 +9838,17 @@ "time": "2026-02-23T13:21:35+00:00" } ], - "aliases": [], + "aliases": [ + { + "package": "sensiolabs/minify-bundle", + "version": "dev-feat/html-support", + "alias": "1.3.0", + "alias_normalized": "1.3.0.0" + } + ], "minimum-stability": "stable", "stability-flags": { + "sensiolabs/minify-bundle": 20, "symfonycasts/tailwind-bundle": 20 }, "prefer-stable": true, diff --git a/config/reference.php b/config/reference.php index c20c02b..179917e 100644 --- a/config/reference.php +++ b/config/reference.php @@ -1289,6 +1289,7 @@ * local_binary?: scalar|Param|null, // Path to the local binary (use "auto" for automatic detection) // Default: false * download_binary?: bool|Param, // Download the binary from GitHub (defaults to "true" in debug mode) // Default: "%kernel.debug%" * download_directory?: scalar|Param|null, // Directory to store the downloaded binary // Default: "%kernel.project_dir%/var/minify" + * version?: scalar|Param|null, // Minify version to download (null for latest) // Default: null * }, * } * @psalm-type ConfigType = array{ diff --git a/src/Shared/Infrastructure/StaticSiteGeneration/FilesystemStaticPageDumper.php b/src/Shared/Infrastructure/StaticSiteGeneration/FilesystemStaticPageDumper.php index a1ca9c9..0ed9c22 100644 --- a/src/Shared/Infrastructure/StaticSiteGeneration/FilesystemStaticPageDumper.php +++ b/src/Shared/Infrastructure/StaticSiteGeneration/FilesystemStaticPageDumper.php @@ -5,6 +5,7 @@ namespace App\Shared\Infrastructure\StaticSiteGeneration; use Sensiolabs\MinifyBundle\Minifier\MinifierInterface; +use Sensiolabs\MinifyBundle\Minifier\Options\HtmlOptions; use Symfony\Component\Filesystem\Filesystem; final readonly class FilesystemStaticPageDumper implements StaticPageDumperInterface @@ -33,9 +34,13 @@ public function dump(string $uri, string $content, ?string $format = null): void $format === 'xml' || str_ends_with($fileName, '.xml') => 'xml', default => null, }; + $options = match ($format) { + 'html' => new HtmlOptions(keepDocumentTags: true), + default => null, + }; if ($minifyType) { - $content = $this->minify->minify($content, $minifyType); // @phpstan-ignore argument.type (the underlying binary supports html/xml) + $content = $this->minify->minify($content, $minifyType, $options); // @phpstan-ignore argument.type (the underlying binary supports html/xml), arguments.count } $this->filesystem->dumpFile(\sprintf('%s/%s', $this->outputDir, $fileName), $content); diff --git a/templates/pages/blog/article.html.twig b/templates/pages/blog/article.html.twig index 043f59b..3ac1bb2 100644 --- a/templates/pages/blog/article.html.twig +++ b/templates/pages/blog/article.html.twig @@ -9,6 +9,7 @@ + diff --git a/templates/pages/blog/index.html.twig b/templates/pages/blog/index.html.twig index a3dca75..b5c9dbf 100644 --- a/templates/pages/blog/index.html.twig +++ b/templates/pages/blog/index.html.twig @@ -8,6 +8,9 @@ + + + {% endblock %} diff --git a/templates/pages/team/index.html.twig b/templates/pages/team/index.html.twig index f74c368..1deef89 100644 --- a/templates/pages/team/index.html.twig +++ b/templates/pages/team/index.html.twig @@ -8,6 +8,9 @@ + + + {% endblock %} diff --git a/templates/pages/website/home.html.twig b/templates/pages/website/home.html.twig index 0bbd8d5..6c6fdad 100644 --- a/templates/pages/website/home.html.twig +++ b/templates/pages/website/home.html.twig @@ -8,6 +8,9 @@ + + +