From 874483eacb5e43fa7b4adcb5f0442e626bf85006 Mon Sep 17 00:00:00 2001 From: Emi Matchu Date: Mon, 9 Sep 2024 19:59:43 -0700 Subject: [PATCH] Fix SassC::SyntaxError when compiling perfectly valid CSS files Okay cool, so this was an error that was happening *only* when building assets for production: Sass's CSS minifier isn't familiar with all modern CSS syntax (I think is the issue?), and so errors on things that are actually totally okay. I had previously worked around this in `swf_assets/show.css` with an equivalent syntax that Sass recognized. But in this latest case with the new `fonts.css.erb`, it was upset about the `src` list for the fonts, and I don't know a workaround for that. So, let's just disable Sass's CSS minification for now. I imagine the difference isn't huge when CSS compresses just fine with gzip anyway? (Most of what you can "minify" in CSS is whitespace, and that largely seems silly to me when gzip is running.) --- app/assets/stylesheets/swf_assets/show.css | 7 ++----- config/application.rb | 1 + 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/app/assets/stylesheets/swf_assets/show.css b/app/assets/stylesheets/swf_assets/show.css index 0c1ba8f5..591f951d 100644 --- a/app/assets/stylesheets/swf_assets/show.css +++ b/app/assets/stylesheets/swf_assets/show.css @@ -4,9 +4,6 @@ position: absolute; left: 0; top: 0; - - /* HACK: `calc` isn't needed, but works around a bug in our asset pipeline, - * where libsass is trying to preprocess it. (We're not SASS tho?) */ - width: calc(min(100vw, 100vh)); - height: calc(min(100vw, 100vh)); + width: min(100vw, 100vh); + height: min(100vw, 100vh); } diff --git a/config/application.rb b/config/application.rb index 74392543..81d27eee 100644 --- a/config/application.rb +++ b/config/application.rb @@ -58,6 +58,7 @@ module OpenneoImpressItems config.assets.paths << Rails.root.join('app', 'assets', 'fonts') config.assets.precompile << '*.js' config.assets.initialize_on_precompile = false + config.assets.css_compressor = nil # Sass's compressor can't handle all modern CSS… config.middleware.insert_after ActionDispatch::Flash, Rack::Attack