Skip to content

Built-in Sass support not working. "Syntax error: Selector "body" is not pure" and other bullshit about non-pure selectors #16050

Answered by mattcarlotta
neeeeecka asked this question in Help
Discussion options

You must be logged in to vote

By design, CSS modules are scoped CSS classes and you'll need to import them within a JS file and apply them to an HTML element’s className.

Example.module.scss

.exampleClassName {
  font-size: 12px;
}

Example.js

import { exampleClassName } from "./Example.module.scss";

const Example = () => 
  <div className={exampleClassName}>
    Scoped example
  </div>;

export default Example;

Selectors like html, body, button, etc are global (unscoped) selectors; in addition they also are not valid scoped classes (like how .exampleClassName is scoped to a div element in the example above). Next expects CSS modules to be pure in that they don’t produce side effects (like altering the body style base…

Replies: 5 comments 7 replies

Comment options

You must be logged in to vote
2 replies
@Yash-Singh1
Comment options

@GabenGar
Comment options

Comment options

You must be logged in to vote
2 replies
@neeeeecka
Comment options

@mizdra
Comment options

Answer selected by neeeeecka
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@GabenGar
Comment options

Comment options

You must be logged in to vote
2 replies
@reorx
Comment options

@SouthLink
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
Converted from issue

This discussion was converted from issue #16050 on August 10, 2020 14:26.