fix: serve theme assets from the production host, keep images on the CDN

This commit is contained in:
fromme committed 2026-09-25 17:35:07 +02:00
1 parent b5d0c484c0
commit f10d784a5c
6 files changed
+59 -57

No files matched your search

@@ -1,17 +1,23 @@
config.tx_replacer {
enable_regex = 1
# The quote character is captured rather than matched literally, because the
# @font-face block in Page/Main.typoscript writes its url() values with single
# quotes - anchoring on `"` alone would skip every font.
# typo3conf is scoped to ep_theme/Resources/Public on purpose: it keeps other
# extensions, Configuration/ and Resources/Private/ out of the CDN.
# The icon sprite is excluded: SVG <use href="...#icon"> may only reference a
# document from the same origin - browsers block an external sprite on the CDN
# host outright, and no CORS header on bunny.net changes that. It has to stay
# on the origin domain or every icon renders empty.
# Only images go to the CDN. The theme's own css/js/fonts are served by the production
# host: they are already minified by Webpack, gzipped by mod_deflate and content-hashed
# for a year of immutable browser caching, and keeping them on the page's own origin
# means they arrive over the connection the browser has already opened rather than
# costing a second DNS lookup and TLS handshake on the critical path.
#
# It also keeps them clear of the pull zone's habit of occasionally wedging a single
# cache key (10.0s -> 504 errorcode 106 until that key is purged, while the origin
# serves the same bytes in under 100ms). For an image that degrades one element; for
# js/main.<hash>.js it would take every visitor's JavaScript down.
#
# typo3temp is scoped to generated images on purpose - assets/compressed holds other
# extensions' concatenated css/js, which belongs on the origin for the same reason.
# The quote character is captured rather than matched literally, so url() values
# written with single quotes are rewritten too.
search {
10 = /(["'])\/?(fileadmin|typo3temp|uploads|typo3conf\/ext\/ep_theme\/Resources\/Public(?!\/images\/icons_sprite\.svg))/
10 = /(["'])\/?(fileadmin|uploads|typo3temp\/assets\/(?:_processed_|images))/
}
replace {
@@ -57,13 +57,21 @@ page {
<link rel="icon" type="image/png" href="/typo3conf/ext/ep_theme/Resources/Public/images/favicon-196x196.png" sizes="196x196">
)
# disableCompression keeps ResourceCompressor's hands off the Encore entries: Webpack
# already minifies them, and copying them to typo3temp/assets/compressed only replaces the
# content hash with a name derived from md5(abspath + mtime + size), which changes on every
# deploy even when the bytes do not - defeating the immutable caching the hash exists for.
# RequestHandler turns this into `compress => false`, which PageRendererHooks forwards to
# typo3_encore's TagRenderer (whose own default it would otherwise override).
includeCSS {
main = typo3_encore:EpThemeConfig:main
main.disableCompression = 1
}
includeJSFooter {
main = typo3_encore:EpThemeConfig:main
main.defer = 1
main.disableCompression = 1
}
10 = FLUIDTEMPLATE
@@ -150,45 +158,6 @@ page {
settings < plugin.tx_eptheme.settings
}
CSS_inlineStyle (
@font-face {
font-family: 'Lato';
font-style: normal;
font-weight: 300;
font-display: swap;
src: local(''),
url('/typo3conf/ext/ep_theme/Resources/Public/fonts/lato-v17-latin-300.woff2') format('woff2'),
url('/typo3conf/ext/ep_theme/Resources/Public/fonts/lato-v17-latin-300.woff') format('woff');
}
@font-face {
font-family: 'Lato';
font-style: normal;
font-weight: 400;
font-display: swap;
src: local(''),
url('/typo3conf/ext/ep_theme/Resources/Public/fonts/lato-v17-latin-regular.woff2') format('woff2'),
url('/typo3conf/ext/ep_theme/Resources/Public/fonts/lato-v17-latin-regular.woff') format('woff');
}
@font-face {
font-family: 'Lato';
font-style: normal;
font-weight: 700;
font-display: swap;
src: local(''),
url('/typo3conf/ext/ep_theme/Resources/Public/fonts/lato-v17-latin-700.woff2') format('woff2'),
url('/typo3conf/ext/ep_theme/Resources/Public/fonts/lato-v17-latin-700.woff') format('woff');
}
@font-face {
font-family: 'Lato';
font-style: normal;
font-weight: 900;
font-display: swap;
src: local(''),
url('/typo3conf/ext/ep_theme/Resources/Public/fonts/lato-v17-latin-900.woff2') format('woff2'),
url('/typo3conf/ext/ep_theme/Resources/Public/fonts/lato-v17-latin-900.woff') format('woff');
}
)
headerData.990 = TEXT
headerData.990 {
value = <script src="{$plugin.tx_eptheme.settings.cookieFirstScriptUrl}"></script>