Replace ruby-sass with dart-sass (node)
-
Review changes -
-
Download -
Patches
-
Plain diff
What does this MR do and why?
This MR removes the deprecated Ruby Sass and replaces it with Dart Sass using the Javascript library.
It introduces cssbundling-rails
to hook into Sprockets Asset Pipeline. Feedback is welcome, and decisions around architecture and references that would require updating would also be useful
Yes thing is potentially a big change, but with it I hope we can move away from Sprockets3, maybe even skip Sprockets4, and move straight to Propshaft and jsbundling-rails.
Status
See - #438278 (closed)
This MR adds cssbundling-rails
alongside sassc-rails
. By default sassc-rails
continues to be used, but cssbundling-rails
can be used by enabling USE_NEW_CSS_PIPELINE
env var.
Proposals
- Introduce a
{ee?,jh?}app/assets/stylesheets/entrypoints
directory, being the single point where all entrypoint CSS files are defined. Then all the files would have to be moved around, but I presume very little will have to be updated- the command would just be
sass app/assets/stylesheets/entrypoints/:app/assets/builds
while everything insideentrypoints/
has the same structure as it does now
- the command would just be
- Possibly introduce PostCSS as a suitable Node based CSS Processor. Adds some tendency of processing Sass files
Hurdles
-
sass
Javascript API is very poor. Meaning the script forbuild:css
can be used to "compile" production assets. But for things like--watch
or the Command Line interface, it's not replicable via the JS API. So we may need to:
- Write super funky JS to construct a command line command to run, both for production and development
- Keep
build:css
for production asset building, and use the JS API to conditionally import EE/JH assets. And use maybe awatch:css
script which invokessass
via CLI
- Think about future of
@import
, as Sass is planning on removing it
MR acceptance checklist
Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
Screenshots or screen recordings
Application still looks and should look exactly the same
Screenshots are required for UI changes, and strongly recommended for all other merge requests.
Before | After |
---|---|
Picture from the Review App
How to set up and validate locally
Clear your local assets: rm -rf public/assets tmp/cache/assets/
. After that a gdk restart rails-web
should be sufficient.
Old way of compiling css
This MR should not mess with the status quo, so starting your gdk
normally, on this branch should have working styles
If you e.g. add body { color: green !important; }
to app/assets/stylesheets/application.scss
, some text color should change to green after a page reload
New way of compiling css
Do the following in one terminal window:
gdk stop
rm -rf public/assets tmp/cache/assets/
export USE_NEW_CSS_PIPELINE=1
gdk start
At the same time, in another terminal window, do:
yarn run build:css --watch
If you now do change e.g. application.scss
, the second terminal window should read: application.scss changed, recompiling
and after a page reload the change you did should be effective.
Comparing assets
This MR also includes a script which runs production compilation of the assets in both modes and places two diffable folders in tmp/css_compare
. Simply run: ./scripts/frontend/compare_css_compilers.sh
. This shows that the production mode is working for both, but we need to figure out the actual diff between the two before we can make the switch.
Merge request reports
- version 42036d2b9e
- version 41da2e7835
- version 401dd1fc55
- version 39fac6e02d
- version 38983d4ea8
- version 37f87aef3f
- version 366e893721
- version 35d33a224b
- version 3473663dc4
- version 330d21b52b
- version 32228be856
- version 31451f936d
- version 30f8e682ee
- version 2991f6ea3b
- version 281a65cf7d
- version 27d82d075c
- version 2697223eaf
- version 2597223eaf
- version 24d50aecd5
- version 2352f8e118
- version 228764322b
- version 21b12362d2
- version 20f05e4577
- version 1902da5401
- version 1825c408fa
- version 176529a708
- version 1686fcc96d
- version 1586fcc96d
- version 14fedc2738
- version 1341b08ed2
- version 1270b1d178
- version 11316f4477
- version 108b04c4b2
- version 98b848621
- version 8ad624137
- version 7226a843a
- version 61dbee659
- version 5042ca269
- version 4cc87551f
- version 32e278535
- version 2f096c332
- version 1d4a8d3dc
- master (base)
- latest versionda57c0f718 commits,
- version 42036d2b9e17 commits,
- version 41da2e783516 commits,
- version 401dd1fc5515 commits,
- version 39fac6e02d14 commits,
- version 38983d4ea813 commits,
- version 37f87aef3f12 commits,
- version 366e89372110 commits,
- version 35d33a224b9 commits,
- version 3473663dc48 commits,
- version 330d21b52b16 commits,
- version 32228be85614 commits,
- version 31451f936d13 commits,
- version 30f8e682ee12 commits,
- version 2991f6ea3b12 commits,
- version 281a65cf7d11 commits,
- version 27d82d075c10 commits,
- version 2697223eaf4 commits,
- version 2597223eaf4 commits,
- version 24d50aecd53 commits,
- version 2352f8e1185 commits,
- version 228764322b4 commits,
- version 21b12362d27 commits,
- version 20f05e45777 commits,
- version 1902da54015 commits,
- version 1825c408fa6 commits,
- version 176529a7086 commits,
- version 1686fcc96d23 commits,
- version 1586fcc96d23 commits,
- version 14fedc273822 commits,
- version 1341b08ed220 commits,
- version 1270b1d17819 commits,
- version 11316f447717 commits,
- version 108b04c4b215 commits,
- version 98b84862114 commits,
- version 8ad62413713 commits,
- version 7226a843a12 commits,
- version 61dbee65911 commits,
- version 5042ca2699 commits,
- version 4cc87551f8 commits,
- version 32e2785357 commits,
- version 2f096c3326 commits,
- version 1d4a8d3dc5 commits,
- Side-by-side
- Inline