Closed a-r-m-i-n closed 1 year ago
From the README of composer-installer-v4:
The public resource URL can not be derived any more from the absolute path to the file by stripping off some path part, but only by passing the absolute path to \TYPO3\CMS\Core\Utility\PathUtility::getAbsoluteWebPath Example: use TYPO3\CMS\Core\Utility\PathUtility; use TYPO3\CMS\Core\Utility\GeneralUtility;
PathUtility::getAbsoluteWebPath(GeneralUtility::getFileAbsFileName('EXT:ext_key/Resources/Public/Icons/Extension.svg'));
Currerently I'm using substr to make the absolute server path relative. That's probably the issue.
The problem with the new assets of composer-installer v4 is, that somehow you need to resolve the hash of the asset/symlink pointing to EXT:my_ext/Resources/Public/
.
In SCSS, to address font files, I need to prepend this to every font file:
$fontPath: '../../../_assets/1031f6efa8587629b685351ed90c99bf/Fonts';
Some questions I have:
@a-r-m-i-n
Does this hash change or is it basically an md5 hash of the path pointing to?
Yes, i think so. The path is always the same id in my tests.
Is there an API existing, to resolve the path to the asset?
TYPO3's internal resource resolver. EXT: ....
Does this hash change or is it basically an md5 hash of the path pointing to?
Yes, i think so. The path is always the same id in my tests.
The hash is derived from the relative composer path of the extension: https://github.com/TYPO3/typo3/blob/main/typo3/sysext/core/Classes/Utility/PathUtility.php#L65-L70
So, it may be, for example: /vendor/typo3/cms-core/
for $relativePrefix
which is then hashed.
But beware: The vendor folder can be configured in a Project's composer.json: https://getcomposer.org/doc/06-config.md#vendor-dir So one should not really rely on the hash in general. For one project (where this configuration is under control) it may be okay when you're knowing what you're doing.
Related to #18
According to https://github.com/a-r-m-i-n/min/issues/11#issuecomment-1211736815 the relative file paths in CSS files are not resolved correctly, when the new composer-installer v4 is involved.