diff --git a/RELEASE.md b/RELEASE.md index c449e963..6b3808d7 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -1,3 +1,9 @@ +# 1.0.0-beta.60 + +- Added extra cache invalidation logic to ensure Sass/Scss files are invalidated whenever any other Sass/Scss files are changed since those are likely imports (#1019). +- Added a new `WebKeys.ChangedFiles` setting to propagate the list of changed files when using the `preview` or `serve` command. +- Updated Statiq Framework reference to version [1.0.0-beta.72](https://github.com/statiqdev/Statiq.Framework/releases/tag/v1.0.0-beta.72). + # 1.0.0-beta.59 - Updated Statiq Framework reference to version [1.0.0-beta.71](https://github.com/statiqdev/Statiq.Framework/releases/tag/v1.0.0-beta.71). diff --git a/src/Statiq.Web/Commands/PreviewCommand.cs b/src/Statiq.Web/Commands/PreviewCommand.cs index 77ee27b3..f7b89c00 100644 --- a/src/Statiq.Web/Commands/PreviewCommand.cs +++ b/src/Statiq.Web/Commands/PreviewCommand.cs @@ -132,6 +132,10 @@ protected override async Task ExecutionTriggeredAsync( logger.LogInformation($"{changedFile} has changed"); } } + + // Use a setting to propagate the list of changed files + engineManager.Engine.Settings[WebKeys.ChangedFiles] = changedFiles; + if (forceExecution || changedFiles.Count > 0) { if (changedFiles.Count > 0) diff --git a/src/Statiq.Web/Commands/ServeCommand.cs b/src/Statiq.Web/Commands/ServeCommand.cs index 43732e0e..2e38e3a5 100644 --- a/src/Statiq.Web/Commands/ServeCommand.cs +++ b/src/Statiq.Web/Commands/ServeCommand.cs @@ -136,6 +136,10 @@ protected override async Task ExecuteEngineAsync( } } + // Use a setting to propagate the list of changed files + engineManager.Engine.Settings[WebKeys.ChangedFiles] = changedFiles; + + // If files have changed, reload if (changedFiles.Count > 0) { logger.LogInformation($"{changedFiles.Count} files have changed, re-loading"); diff --git a/src/Statiq.Web/Templates/Templates.cs b/src/Statiq.Web/Templates/Templates.cs index d5f7d407..0524e9b1 100644 --- a/src/Statiq.Web/Templates/Templates.cs +++ b/src/Statiq.Web/Templates/Templates.cs @@ -2,6 +2,7 @@ using System.Collections; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; +using System.IO; using System.Linq; using Statiq.Common; using Statiq.Core; @@ -22,7 +23,13 @@ public Templates() { // Assets Add(MediaTypes.Less, new Template(ContentType.Asset, Phase.Process, new CacheDocuments { new CompileLess() })); - Add(MediaTypes.Sass, new Template(ContentType.Asset, Phase.Process, new CacheDocuments { new CompileSass().WithCompactOutputStyle() })); + Add(MediaTypes.Sass, new Template( + ContentType.Asset, + Phase.Process, + new CacheDocuments { new CompileSass().WithCompactOutputStyle() } + .InvalidateDocumentsWhere( + Config.FromContext( + ctx => ctx.GetList(WebKeys.ChangedFiles)?.Any(x => MediaTypes.IsMediaType(x, MediaTypes.Sass, MediaTypes.Scss)) == true)))); Add(MediaTypes.Scss, this[MediaTypes.Sass]); // Data diff --git a/src/Statiq.Web/WebKeys.cs b/src/Statiq.Web/WebKeys.cs index 9f714393..6f3b287e 100644 --- a/src/Statiq.Web/WebKeys.cs +++ b/src/Statiq.Web/WebKeys.cs @@ -330,6 +330,11 @@ public static class WebKeys /// public const string IgnoreInvalidXrefs = nameof(IgnoreInvalidXrefs); + /// + /// Set by the preview and serve commands to indicate which files have changed and triggered execution. + /// + public const string ChangedFiles = nameof(ChangedFiles); + ////////// Document ///