Error: Undefined variable in sass-rails 6, but in sass-rails 5 works fine

258 views Asked by At

I've a problem with sass-rails 6 on Rails 6.1.2.1.

In my project styles i need to change textflow left-to-right (ltr) and right-to-left (rtl) depending on selected language. But it seems to be broken in 'sass-rails', '>= 6'. it raised: Undefined variable.

ActionView::Template::Error: 00:14
Error: Undefined variable: "$dir".
on line 17:14 of app/assets/stylesheets/_application.sass 00:14
>>   direction: $dir;

Here's my file structure:

# _ltr.sass

$dir: ltr
$left: left
$right: right
# _rtl.sass

$dir: rtl
$left: right
$right: left
# application.rtl.sass

@import ./_rtl
@import ./_application
# application.ltr.sass

@import ./_ltr
@import ./_application
# _application.sass

html
  font-size: 10px
  height: 100%
  width: 100%

body
  background-color: $white
  color: $black
  cursor: default
  direction: $dir

Is this behavior expected?

How to import variables in sass-rails 6, what has changed between version 5 and 6 in this usecase?

Thanks!

0

There are 0 answers