N
N
Nikolai Dombrovsky2016-05-08 18:29:32
Ruby on Rails
Nikolai Dombrovsky, 2016-05-08 18:29:32

How to properly import scss files into a Rails project?

Good afternoon. Small question.
I'm doing a project on RoR. Question about sass.
The structure of the project assets is divided into folders. Scss are imported into main.

//application.scss

@import "variables"
@import "mixins"

@import "pages/home"

But the files do not see mixins and variables declared in separate files.
I googled a lot, I just wouldn’t write like that. I used to solve the problem by importing files with mixins and variables in each file, but this is not the case ...
Here's what sass-rails says

Answer the question

In order to leave comments, you need to log in

2 answer(s)
N
Nikolai Dombrovsky, 2016-05-10
@nDiviD

The problem arises because Rails precompiles each file separately. In config application.rb, you need to change assets.precompile, remove *.css from there

C
Clever_Coyote, 2016-05-10
@Clever_Coyote

If variables/mixins are declared in other files besides variables & mixins, then in order to be used in other files, you need to import the file with mixins/variables before the file where they are declared.
It's better not to declare global variables in other files.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question