'Wrap child scss file with parent class

Is there a way to add a parent class to all rules in a child scss file. By interpreting the child file as if it was already compiled?

Currently, I tried to wrap an @import with a parent class but it doesn't work as expected.

parent.scss

.parent{
   @import 'child';
}

child.scss

.child{
   .dark &{
      color: blue;
   }
}

Actual output

.dark .parent .child {
  color: blue; 
}

Expected output

.parent .dark .child {
  color: blue; 
}



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source