Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use dartsass-rails vs sassc-rails #2709

Merged
merged 4 commits into from
Feb 13, 2024
Merged

Conversation

floehopper
Copy link
Contributor

@floehopper floehopper commented Feb 12, 2024

LibSass is now deprecated, so I followed these instructions in the GOV.UK Developer Docs to make the change. Once it's merged, there's also a corresponding change to govuk-docker that will need to me made - see this PR.

This should address the following Bundler post-install message is was seeing:

govuk_publishing_components has now migrated to dartsass-rails from sassc-rails for stylesheet compilation since LibSass is deprecated. While both implementations are supported, it is recommended to update your application to use the latest implementation of Sass (dartsass-rails). You can find further details in the docs - https://docs.publishing.service.gov.uk/manual/migrate-to-dart-sass-from-libsass.html.

I've tested this locally using the modified version of govuk-docker and verified that I can make changes to CSS and see them reflected in the rendered pages. I've also run RAILS_ENV=production rails assets:precompile locally and I don't see any errors or warnings.

c.f. alphagov/support#1253

floehopper added a commit to alphagov/govuk-docker that referenced this pull request Feb 13, 2024
When I moved [1] the signon app from libsass to dart-sass following
these instructions [2], I created a new `bin/dev` file which runs two
processes in `Procfile.dev`, one of which runs the rails server and
another which runs `dart-sass` in watch mode. This updates the
`docker-compose.yml` file accordingly.

[1]: alphagov/signon#2709
[2]: https://docs.publishing.service.gov.uk/manual/migrate-to-dart-sass-from-libsass.html
@chrisroos chrisroos self-assigned this Feb 13, 2024
Copy link
Contributor

@chrisroos chrisroos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apart from the inclusion of application.css in the builds directory this all looks good to me, @floehopper 👍

This code re-defines the assets-related tasks in order to avoid a load
of INFO-level warnings generated by the assets:precompile task [1].

It wasn't immediately obvious to me that was what was happening (even
though I made the change!). I think moving the code into a separate
`lib/tasks/assets.rake` file is more idiomatic and makes it slightly
more obvious what's going on.

[1]: #2179
The `dartsass-rails` gem does this enhancement automatically. However,
because we re-define the `assets:precompile` task, we lose the
enhancement and have to re-add it here.

c.f. alphagov/whitehall@13bd112
This fixes the following deprecation warning:

    Using / for division outside of calc() is deprecated and will be removed in Dart Sass 2.0.0.
    Recommendation: math.div($sort-link-arrow-size, 2) or calc($sort-link-arrow-size / 2)
    More info and automated migrator: https://sass-lang.com/d/slash-div
@floehopper floehopper force-pushed the use-dartsass-rails-vs-sassc-rails branch from 216c6ea to dc16605 Compare February 13, 2024 14:55
@floehopper floehopper merged commit ee40432 into main Feb 13, 2024
16 checks passed
@floehopper floehopper deleted the use-dartsass-rails-vs-sassc-rails branch February 13, 2024 15:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants