sabbelasichon / typo3_encore

Use Webpack Encore within TYPO3
Other
106 stars 19 forks source link

Error with Asset Viewhelper linking assets from extension with version 5.0.2 #183

Closed cowboyxup closed 1 year ago

cowboyxup commented 1 year ago

Description Getting following error with the extension 5.0.2. In version 5.0.1 it's works fine. grafik

Enviroment TYPO3 11.5.21 with typo3/cms-composer-installers": "^3" The webpack configuration with the public path in the typo3conf/ext/.. direcory is used: https://github.com/pfadfinden/bdp_template/blob/main/webpack.config.mjs The issue was testet with a new isolated ddev enviroment.

Debugging The used fluid code is: <f:image src="{encore:asset(pathToFile: 'EXT:bdp_template/Resources/Public/Build/images/bundeszeichen.png')}" alt="Pfadfinden Logo" class="brand__box__logo__image"/>

The issue can be traced back to the function https://github.com/sabbelasichon/typo3_encore/blob/59bc1cd75a76658ebdf0048cc184f7c5f975d66b/Classes/ViewHelpers/AssetViewHelper.php#L53 introduced in https://github.com/sabbelasichon/typo3_encore/pull/176/

This function returns: images/bundeszeichen.png instead of the required typo3conf/ext/bdp_template/Resources/Public/Build/images/bundeszeichen.png to resolve the file in the manifest.json.

If i insert the following code in the function from the code in 5.0.1 it works as expected.

if (\str_starts_with($absolutePathToFile, Environment::getPublicPath())) {
            return PathUtility::stripPathSitePrefix($absolutePathToFile);
        }
return substr($absolutePathToFile, strlen(dirname($absolutePathToManifestJson) . '/'));

Further steps I don't now the logic and idea behind the new substr approach, so that i can't create a fix pull-request for this issue.