next.js icon indicating copy to clipboard operation
next.js copied to clipboard

Nextjs and sass @extend

Open Lukortech opened this issue 4 years ago • 2 comments

What version of Next.js are you using?

11

What version of Node.js are you using?

14.17.4

What browser are you using?

Chrome

What operating system are you using?

Windows 10

How are you deploying your application?

dev

Describe the Bug

Nextjs doesn't support sass @extend properly in .module.scss files.

Expected Behavior

I should be able to use styles\globals.scss

.centerTransform {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
}

class in pages\settings\some-module.scss via @extend

.someClass {
  @extend .centerTransform;
}

To Reproduce

Check the ongoing discussion in this "closed" issue.

https://github.com/vercel/next.js/issues/10475

Lukortech avatar Aug 25 '21 19:08 Lukortech

You can achieve it by using import at the beginning of your .module.scss file

@import '../../styles/globals.scss';

.myClass {
  @extend .centerTransform;
}

guitheengineer avatar Aug 31 '21 11:08 guitheengineer

I'm using Next.js v12.3.1 and still unable to use @extend of Sass.

gitChang avatar Nov 07 '22 12:11 gitChang

I still can't use the SCSS @extend with v13.4.19.

th0th avatar Sep 06 '23 01:09 th0th