EGN
EGN

Reputation: 2572

SASS import a file without nesting

I need to combine an SCSS file into a namespace but I don't want to modify the file directly.

Assume, we have "book.scss" that contains

.book {
   color: red;
}

if I want to import the file into a namespace using

.context {
    @import 'book';
}

This will produce a nested selector

.context .book {
    color: red;
}

However, I want it in this way. Notice there is no space between context and book

.context.book {
    color: red;
}

Is this possible with SASS?

Upvotes: 1

Views: 422

Answers (1)

omukiguy
omukiguy

Reputation: 1437

There is no way. You will just have to import the file and then extend the class

.context.book {
    @extend .book;
}

Upvotes: 4

Related Questions