thepensionsregulator / govuk-frontend-aspnetcore-extensions

Adds client-side validation, additional components and editing in Umbraco to https://github.com/gunndabad/govuk-frontend-aspnetcore
MIT License
16 stars 1 forks source link

CSS files generated from SASS were getting deleted immediately after they were created #317

Closed sussexrick closed 3 months ago

sussexrick commented 3 months ago

If you have *.scss files in a Styles folder in your project and you reference the AspNetCore.SassCompiler package directly, it should create a corresponding *.css file in the wwwroot\css folder.

These projects were referencing AspNetCore.SassCompiler v1.71.1.1 and using that version worked. However, if the consuming project referenced a newer version the *.css files got created and then immediately deleted. This appears to be a race condition between a cleanup task in our package which deletes the *.css files and the generation of the files.

This PR moves the cleanup task earlier in the build lifecycle, alongside other cleanup tasks. This gives it time to finish before the generation of new files happens, meaning that newer versions of AspNetCore.SassCompiler can be used. It upgrades our dependency to the latest.

We also generate a placeholder site.css for Umbraco projects if none exists, to avoid a 404 in the backoffice where we configure the rich text editor to load site.css so that it can display our custom styles. This PR improves the condition for generating that file, avoiding wasteful generation and any potential conflict if there is a Styles\site.scss file present which would replace it moments later.

Fixes #300.