alphagov/whitehall

Can't upgrade to newer govuk_publishing_components

kevindew opened this issue · 2 comments

There are regular PR's coming through for each govuk_publishing_components update and failing. For example: #4723. @alex-ju and I spent a while looking at the problem and this catalogues our results.

These are failing since the introduction of the following code on govuk-frontend: @supports (margin: unquote("max(calc(0px))")) { and this only fails on production asset:precompile not development.

Our theory is that the SCSS is effectively processed twice. Once to build the scss file and a second time to compress them. At the second pass of the file the unquote has been removed and thus SCSS is treating max as a sass function rather than a CSS function.

We saw this debugging the sassc-rails compressor (https://github.com/sass/sassc-rails/blob/master/lib/sassc/rails/compressor.rb#L24-L29) and putting in a byebug had the following results:

Given an input of:

p {
  padding-right: unquote("max(calc(0px))");
}

an output of:

[20, 29] in /Users/kevindew/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/sassc-rails-2.1.0/lib/sassc/rails/compressor.rb
   20:     else
   21:       args[0][:data] #sprockets 3.x
   22:     end
   23:     require "byebug"; byebug # DEBUG @kevindew
   24:
=> 25:     SassC::Engine.new(
   26:       input,
   27:       {
   28:         style: :compressed
   29:       }
(byebug) input
"/* line 1, app/assets/stylesheets/application.scss */\np {\n  padding-right: max(calc(0px));\n}\n"
(byebug) c
rake aborted!
SassC::SyntaxError: Error: "calc(0px)" is not a number for `max'
        on line 3 of stdin, in function `max`
        from line 3 of stdin
>>   padding-right: max(calc(0px));

similar problem in finder-frontend

This is now resolved with 5d98c51