SASS :export does not work with built-in SASS support throwing 'Selector ":export" is not pure'
See original GitHub issueBug report
Describe the bug
I use :export
syntax to export variables from scss files and import them in JS. This worked great with next-sass, but does not even compile with the built-in SASS support.
To Reproduce
in Component.jsx
:
import colors from './component.module.scss'
component.module.scss
:
:export {
white: #ffffff;
black: #000000;
}
Expected behavior
colors
in Component.jsx
should be an object that looks something like this:
{
white: "#ffffff",
black: "#000000"
}
Actual behavior
It does not compile the scss file and throws:
ModuleBuildError: Module build failed (from ./node_modules/next/node_modules/css-loader/dist/cjs.js):
CssSyntaxError
(1:0) Selector ":export" is not pure (pure selectors must contain at least one local class or id)
System information
- OS: Windows 10 (WSL)
- Version of Next.js: 9.3.4
- Version of SASS: 1.26.3
Additional information
next.config.js
does not contain any code related to CSS or SASS
Issue Analytics
- State:
- Created 3 years ago
- Reactions:20
- Comments:11 (3 by maintainers)
Top Results From Across the Web
Cannot Export Sass Variables into Javascript - Stack Overflow
Personally, I like to import my SCSS variables, and then, export them ... _export.scss is only utilised in JS files, and is not...
Read more >Sass: @use
The simplest @use rule is written @use "<url>" , which loads the module at the given URL. Any styles loaded this way will...
Read more >Features In-Depth | Less.js
Selector Interpolation with Extend. Extend is not able to match selectors with variables. If selector contains variable, extend will ignore it. However, extend ......
Read more >sass-loader - webpack - JS.ORG
This allows you to control the versions of all your dependencies, and to choose which Sass implementation to use. Note. We highly recommend...
Read more >Global vs. Local Styling In Next.js - Smashing Magazine
Not only does Next.js support doing so with no additional setup; ... SASS in a project if I find I need other SASS...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@lipoolock I had to rename my
variables.scss
tovariables.module.scss
for this feature to work (from a hint here). That was all!The issue is that the built-in
css-loader
options are using by default “pure” CSS modules. I managed to work around this issue by updating this option for the specific css modules files that we use in our project (.module.scss):I’m not entirely sure of all the implications that this change might have…