From b9d7b7529935d9e977f4d8b0cd26a9e46d26110f Mon Sep 17 00:00:00 2001 From: Jon Uhlmann Date: Fri, 14 Aug 2020 13:32:13 +0200 Subject: [PATCH] :sparkles: Add option to disable cache buster for PreloadAsset --- Configuration/Settings.yaml | 1 + Resources/Private/Fusion/External/Collection.fusion | 9 ++++++++- Resources/Private/Fusion/External/File.fusion | 4 +++- Resources/Private/Fusion/Internal/Package.fusion | 9 ++++++++- Resources/Private/Fusion/Internal/Tag.fusion | 2 ++ 5 files changed, 22 insertions(+), 3 deletions(-) diff --git a/Configuration/Settings.yaml b/Configuration/Settings.yaml index 8812f51..3965aa5 100644 --- a/Configuration/Settings.yaml +++ b/Configuration/Settings.yaml @@ -30,6 +30,7 @@ Carbon: Default: Package: SitePackage CacheBuster: true + DisableCacheBusterForPreloadAsset: true ConditionPrototype: null Path: Inline: diff --git a/Resources/Private/Fusion/External/Collection.fusion b/Resources/Private/Fusion/External/Collection.fusion index 1fb91bf..f1fafa8 100644 --- a/Resources/Private/Fusion/External/Collection.fusion +++ b/Resources/Private/Fusion/External/Collection.fusion @@ -6,11 +6,18 @@ prototype(Carbon.IncludeAssets:Collection) < prototype(Neos.Fusion:Component) { collection = ${[]} assetPackage = null cacheBuster = ${Configuration.setting('Carbon.IncludeAssets.Default.CacheBuster')} + disableCacheBusterForPreloadAsset = ${Configuration.setting('Carbon.IncludeAssets.Default.DisableCacheBusterForPreloadAsset')} paths = ${Configuration.setting('Carbon.IncludeAssets.Default.Path')} renderer = afx` - + ` } diff --git a/Resources/Private/Fusion/External/File.fusion b/Resources/Private/Fusion/External/File.fusion index 80c4336..e579dc9 100644 --- a/Resources/Private/Fusion/External/File.fusion +++ b/Resources/Private/Fusion/External/File.fusion @@ -6,6 +6,7 @@ prototype(Carbon.IncludeAssets:File) < prototype(Neos.Fusion:Component) { file = null assetPackage = ${node.context.currentSite.siteResourcesPackageKey} cacheBuster = ${Configuration.setting('Carbon.IncludeAssets.Default.CacheBuster')} + disableCacheBusterForPreloadAsset = ${Configuration.setting('Carbon.IncludeAssets.Default.DisableCacheBusterForPreloadAsset')} assetPath = null // This is a internal variable, please use `assetPath` for an single file @@ -17,6 +18,7 @@ prototype(Carbon.IncludeAssets:File) < prototype(Neos.Fusion:Component) { file = ${props.file} assetPackage = ${props.assetPackage} cacheBuster = ${props.cacheBuster} + disableCacheBusterForPreloadAsset = ${props.disableCacheBusterForPreloadAsset} assetPath = ${props.assetPath ? props.assetPath : props.paths[this.assetKey][this.type]} fileObject = ${Carbon.IncludeAssets.parseFilename(props.file)} @@ -50,7 +52,7 @@ prototype(Carbon.IncludeAssets:File) < prototype(Neos.Fusion:Component) { ` preload = afx` - + ` modulePreload = afx` diff --git a/Resources/Private/Fusion/Internal/Package.fusion b/Resources/Private/Fusion/Internal/Package.fusion index b1fb4ca..ce4c253 100644 --- a/Resources/Private/Fusion/Internal/Package.fusion +++ b/Resources/Private/Fusion/Internal/Package.fusion @@ -24,6 +24,7 @@ prototype(Carbon.IncludeAssets:Internal.Package) < prototype(Neos.Fusion:Compone } assetPackage = ${props.mergedConfig.Package == 'SitePackage' ? node.context.currentSite.siteResourcesPackageKey : props.mergedConfig.Package} cacheBuster = ${props.mergedConfig.CacheBuster} + disableCacheBusterForPreloadAsset = ${props.mergedConfig.DisableCacheBusterForPreloadAsset} paths = ${props.mergedConfig.Path} collection = Neos.Fusion:RawCollection { collection = ${['General', 'Backend', 'Live']} @@ -36,7 +37,13 @@ prototype(Carbon.IncludeAssets:Internal.Package) < prototype(Neos.Fusion:Compone } renderer = afx` - + ` } } diff --git a/Resources/Private/Fusion/Internal/Tag.fusion b/Resources/Private/Fusion/Internal/Tag.fusion index 033f3ef..fcb779e 100644 --- a/Resources/Private/Fusion/Internal/Tag.fusion +++ b/Resources/Private/Fusion/Internal/Tag.fusion @@ -31,6 +31,8 @@ prototype(Carbon.IncludeAssets:Internal.Tag) < prototype(Neos.Fusion:Component) prototype(Carbon.IncludeAssets:Internal.Tag.ResourceHint) < prototype(Carbon.IncludeAssets:Internal.Tag) { async = false rel = null + disableCacheBusterForPreloadAsset = true + cacheBuster.@process.disableForPreloadasset = ${this.disableCacheBusterForPreloadAsset && this.fileObject && this.fileObject.type == 'PRELOADASSET' ? false : value} @if.hasRel = ${this.rel} renderer.resourceHint = ${''} }