a-r-m-i-n / min

TYPO3 CMS extension "min" - Compressed CSS, JS and HTML output for TYPO3
7 stars 8 forks source link

Compression with fonts inside CSS #23

Closed nogueiraludovic closed 1 month ago

nogueiraludovic commented 5 months ago

When fonts are preloaded in HTML, they are stored in /_assets/XYZ/font.woff2. But when compressing CSS it is stored inside /typo3temp/assets/compressed. Now with a relative path inside the CSS we would like to hit the folder "/_assets/XYZ/font.woff2", but instead we are given this kind of URL: https://XYZ.ddev.site/vendor/typo3/extension/Resources/Public/Css/fonts/TheMix/font.woff2.

Is their a way to call the font inside _assets directory?

a-r-m-i-n commented 5 months ago

The only solution I know for this, is to use an absolute path in CSS file, to /_assets/abcdef01234...

Of course this not ideal... Let me think about a better solution.

nogueiraludovic commented 5 months ago

Not ideal, yeah, but I tought the folder name was randomly generated. But I saw that it was the same on all environment, so it could work.

Another idea my colleague had was to write EXT:extension/Resources/Public/font.woff2 in the CSS and to parse EXT: and replace it with PathUtility::getPublicResourceWebPath. The problem here is that we don't necessarily want the compression in dev environment.

Kinda hard issue, let me know if you come with an idea.

a-r-m-i-n commented 5 months ago

Another solution could be, to outsource the custom fonts to a separate css file and exclude this file from concatenation and compression.

a-r-m-i-n commented 5 months ago

And the hash in _assets folder is based on the "/vendor/blubb/blah/" path.

As long as you do not rename the package or vendor name or the vendor folder itself, the MD5 hash remains the same in all environments.

Patta commented 5 months ago

https://github.com/a-r-m-i-n/min/issues/12

nogueiraludovic commented 5 months ago

Ok, so it strengthened my hate for this change in typo3 12.

Anyway I'll go with the link to the _assets folder. I let you close this issue if you don't see any other workaround. Maybe it can be a good idea to add something in the doc.