0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

CSS Modules で :global を使うと「Error: Missing whitespace after :global」と言われてしまう件

Posted at

下記のような書き方をすると Error: Missing whitespace after :global と言われてしまった。
書き方は間違えてないはずなんだけどなあ。

test.module.scss
.container {
  :global {
    &.active {
      color: red;
    }
  } 
}

どうやら css-loader に含まれている postcss-modules-local-by-default の不具合らしい。
https://github.com/webpack-contrib/sass-loader/issues/507#issuecomment-351065764

PostCSSの設定を変更すれば回避できるらしいけど、気軽に設定を触れる環境ではなかったので書き方で回避した。

test.module.scss
.container {
  &:global(.active) {
    color: red;
  } 
}

ま、これでいいか

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?