FIX: Replace R2 gem with rtlcss for generating RTL CSS (#19636)

We've had a couple of problems with the R2 gem where it generated a broken RTL CSS bundle that caused a badly broken layout when Discourse is used in an RTL language, see a3ce93b and 5926386. For this reason, we're replacing R2 with `rtlcss` that can handle modern CSS features better than R2 does.

`rltcss` is written in JS and available as an npm package. Calling the `rltcss` from rubyland is done via the `rtlcss_wrapper` gem which contains a distributable copy of the `rtlcss` package and loads/calls it with Mini Racer. See https://github.com/discourse/rtlcss_wrapper for more details.

Internal topic: t/76263.
This commit is contained in:
Osama Sayegh
2023-02-01 14:21:15 +03:00
committed by GitHub
parent 66256c15bd
commit f94951147e
6 changed files with 15 additions and 27 deletions

View File

@ -214,4 +214,11 @@ RSpec.describe Stylesheet::Compiler do
expect(refs).to eq([])
end
end
describe ".compile" do
it "produces RTL CSS when rtl option is given" do
css, _ = Stylesheet::Compiler.compile("a{right:1px}", "test.scss", rtl: true)
expect(css).to eq("a{left:1px}")
end
end
end