Scss not reflected in haml as intended

Asked 2 years ago, Updated 2 years ago, 109 views

The _tweets.scss you want to reflect in views/tweets/index.html.haml is listed as assembets/modules/_tweets.scss.

application.scss can be found in

@import "reset";
@import "font-awesome-sprockets";
@import "font-awesome";
@import "modules/tweets";
@import "modules/index";

However, the modules/index scss is reflected in the haml.

How can it be reflected as above?
I'm sorry for my poor writing, but I'd appreciate it if someone could tell me.

ruby-on-rails haml scss

2022-09-30 15:45

1 Answers

The style of modules/_index.scss imported later overrides the style set in modules/_tweets.scss, so you can change the import order as follows:

@import "reset";
@import "font-awesome-sprockets";
@import "font-awesome";
@import "modules/index";
@import "modules/tweets";

Consider the following SCSS:

//style.scss
@import "tweets";
@import "index";

// _tweets.scss
.hoge{
  color:red;
}

// _index.scss
.hoge{
    color:blue;
}

Convert style.scss to CSS and you'll see the following (we experimented with https://sass.js.org/):

.hoge{
  color:red;
}

.hoge{
  color:blue;
}

The CSS applies the properties written after the CSS in principle, so color:blue; is applied and color:red; is ignored.


2022-09-30 15:45

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.