Alternative to smidge in v14
# help-with-umbraco
c
What is the alternative to smidge in v14 because I see it isn't bundled with Umbraco anymore? I'm thinking about on the front end of the website, not the umbraco side. Are there any docs for this please?
s
Use Smidge!
It's just a NuGet package: > A lightweight runtime CSS/JavaScript file minification, combination, compression & management library for ASP.Net Core
k
Speaking of Smidge, what are people using for runtime/automatic sass compilation in 14? We've used Ligershark and AspNetCoreSassCompiler previously, but they feel a bit dated-
d
Dart Sass has a one-line watch and compile, I ❤️ it. https://sass-lang.com/documentation/cli/dart-sass/
j
💯 what @Dean Leigh said. Dart Sass is the Sass compiler. It's always best to use frontend tooling for compiling frontend code. If you need JavaScript support too then use something like Vite. These are really build-time concerns. A live web app shouldn't being having to worry about compiling frontend assets and the reality is that CSS and JS moves too quickly for .NET libraries to keep up with the features.
Not to dump too much on Smidge though, it's a nice idea that can work well for sites with a more old-fashioned CSS/JS implementation. The problem is when Freddie-front-end comes along and writes some CSS/JS that causes a 500 error (should that even be possible?). Waiting on a PR two-dependencies deep to be able to use CSS that the browser understands but a .NET lib doesn't is bonkers.
c
So @Jason are you saying you don't bother with Smidge nowadays? If so, how do you let the browser know the assets have changed?
and is environment aware 🙂
j
The above (or similar) for non-Vite builds.
For Vite builds, Vite automatically appends a hash to the filename on build.
(the hash is a hash of the contents, so it can be cached indefinitely)
m
And the above helper lets you do wildcarding 🙂
j
Yes, in some builds I have a wildcard to just load whatever's there (in that scenario, old files must get nuked as part of deplpoyment) In others I use a manifest.
c
This is good, so firstly for non vite builds how do you set the version and then secondly when deploying how can we set that version using CI/CD
k
Whappened to ETag and If-None-Match. That was supposed to non-problemize all this
j
They're nice but they still require a HTTP request to actually do the comparison.
Caching based on filename means a request only gets made if absolutely necessary.
m
asp-append-version="true"
on the tag
it will add the hash as aquerystring
c
The hash of the file contents?
m
Yeah so if it updates the hash changes
c
Brill, what about script tags?
m
yep
there is loads of options on link and script tags if you do asp-
I have to say the offical docs on the helpers are rubbish as usual
j
Haha, yeah. I don't think
asp-append-version="true"
necessary if you're using the wildcard?
with Vite hashed files.
m
Yeah not needed if you file names a hash in them
@Jason what if two version of the file are on teh server, does it take just the latest (I keep meaning to test this)
j
It loads both.
m
we normally delete files on deploy but always wondered 😄
j
Ditto. The problem I always had with version/timestamp based cache invalidation was transient environments kind of break it and new version numbers would be used for files that haven't changed between deployments. Hashing solves that problem.
c
This is great, thank you. So I can just disregard smidge now and use the
asp-append-version="true"
as long as I have already taken care of the bundling and minification with the build tools. Thanks all, I'm glad I asked now.
280 Views