Starting with TYPO3 v12 extensions are no longer inside the webserver's document root and the Resources/Public folder is symlinked to _assets/SOME-RANDOM-HASH. When adding CSS, JavaScripts or images within the template by TypoScript or Fluid you can use EXT:my_extension_name to link into the extensions Resources/Public folder but what possibilities or strategies are there when you're running a multi site TYPO3 with one main theme and multiple subthemes that're using files (images, fonts, ...) from the main theme?
Because extensions are used to define the websites 'theme' or 'template', I see no security issue when using the real extension name for the symlink in _assets for these 'extensions'. So is there an option (for example within the composer.json) to use the extension's real name when symlinking it?
Are there any 'best practices' on linking to static files that are part of the website's theme?
Currently we solved that problem by generating symlinks to the theme's public folders and therefore are using somework/composer-symlinks. Unfortunately it still depends on Composer v1, so you can use the patched fork from mhauri/composer-symlinks and copy it to your /extensions/
folder.
Your composer file could look like that (not a complete configuration, only relevant lines are shown here!)
{
"repositories": [
{
"type": "path",
"url": "extensions/*",
"options": {
"symlink": true
}
}
],
"require": {
"somework/composer-symlinks": "dev-master",
"my/main-theme": "@dev"
},
"extra": {
"somework/composer-symlinks": {
"symlinks": {
"extensions/main_theme/Resources/Public" : "public/_assets/main_theme"
}
}
},
"config": {
"allow-plugins": {
"somework/composer-symlinks": true
}
}
}