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

Switch Sass compilation from node-sass to dart-sass #6033

Closed
wants to merge 6 commits into from

Conversation

thibaudcolas
Copy link
Member

@thibaudcolas thibaudcolas commented May 15, 2020

Includes the changes from #5401. I had trouble with dependencies shared between node-sass and Jest 22 (jsdom 11.5) – this resolves those problems quite conveniently.

This replaces gulp-sass with a fork using the new Dart implementation of Sass, https://github.com/sass/sass. This implementation is now the canonical implementation for Sass, so is more up to date (e.g. @use) – and also much easier to keep up to date on projects, since it’s compiled to JavaScript for the npm package, not needing native modules like node-sass does.

This should make it much easier for contributors to switch between working on a Vagrant box, Docker, their own computer – node-sass is our only dependency requiring native modules (there’s fsevents too but it’s optional). It also makes it easier to upgrade Node versions, since we don’t have to worry about node-sass having prebuilt binaries for the versions we upgrade to.

This also makes the Draftail.css compilation warning go away.


As part of the upgrade I had to rewrite two bits of code that were using now-deprecated Sass features. The output CSS for those two features. The output CSS is overall nearly identical – there are a few things that are ordered differently in a way that’s not significant, and a different level of precision for math, not in a way that’s significant.

I tested this with my UI regression test suite from https://github.com/thibaudcolas/wagtail-tooling.


  • Do the tests still pass? (https://docs.wagtail.io/en/latest/contributing/developing.html#testing)
  • Does the code comply with the style guide? (Run make lint from the Wagtail root)
  • [x] For Python changes: Have you added tests to cover the new/fixed behaviour?
  • For front-end changes: Did you test on all of Wagtail’s supported browsers? Please list the exact versions you tested.
  • For new features: Has the documentation been updated accordingly?

Once this is merged we can remove: https://github.com/wagtail/docker-wagtail-develop/blob/eef59861b590ffabb54fd7c29271a4a39d9de071/Dockerfile.frontend#L9-L10

and might also be able to change: https://github.com/wagtail/vagrant-wagtail-develop/blob/master/Vagrantfile#L35.

Jest 24 is out but upgrading to it would require us to also update our Webpack tooling to Babel 7, which is quite significant work.
@squash-labs
Copy link

squash-labs bot commented May 15, 2020

Manage this branch in Squash

Test this branch here: https://thibaudcolaschoredart-sass-hsfu4.squash.io

Copy link
Member

@lb- lb- left a comment

Choose a reason for hiding this comment

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

@thibaudcolas - great stuff! This is so much easier to work with when developing, should be a great help to all those working with styles. Tested a bunch of stuff, reviewed code and cannot see any issues. Will aim to merge in shortly.

  • npm ci (in vm)
  • npm run lint
  • npm run build (in vm & outside vm) + delete static before
  • visual validation across app
  • check icons render in form, time & url field

lb- added a commit to wagtail/vagrant-wagtail-develop that referenced this pull request May 17, 2020
* native modules no longer used for sass due to adoption of `dart-sass`
* wagtail/wagtail#6033
* wagtail/wagtail@7eeb44a
lb- added a commit to lb-/docker-wagtail-develop that referenced this pull request May 17, 2020
* native modules no longer used for sass so no rebuild required (adoption of `dart-sass`)
* wagtail/wagtail#6033
* wagtail/wagtail@7eeb44a
@lb-
Copy link
Member

lb- commented May 17, 2020

Merged in via 7eeb44a

PRs created as noted to remove node-sass specific build workarounds in docker/vagrant

@lb- lb- closed this May 17, 2020
@thibaudcolas thibaudcolas deleted the chore/dart-sass branch May 17, 2020 18:24
lb- added a commit to wagtail/vagrant-wagtail-develop that referenced this pull request May 18, 2020
* native modules no longer used for sass due to adoption of `dart-sass`,  node-sass no longer needing to be mentioned
* wagtail/wagtail#6033
* wagtail/wagtail@7eeb44a
allcaps pushed a commit to wagtail/docker-wagtail-develop that referenced this pull request May 19, 2020
* native modules no longer used for sass so no rebuild required (adoption of `dart-sass`)
* wagtail/wagtail#6033
* wagtail/wagtail@7eeb44a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants