You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+9-9Lines changed: 9 additions & 9 deletions
Original file line number
Diff line number
Diff line change
@@ -4,15 +4,15 @@
4
4
5
5
[PostCSS] plugin to transform global selectors into the [local scope] format of [Webpack]'s [css-loader].
6
6
7
-
**WARNING: This project depends on [css-loader]'s [local scope] feature, which is marked as experimental and is very likely to change in the future.**
7
+
**WARNING: This project depends on [css-loader]'s [local scope] feature, which is marked as experimental and is very likely to change in the future. Always ensure you're using the latest version of both [css-loader] and postcss-local-scope together.**
8
8
9
9
## Why?
10
10
11
11
Everyone agrees that dumping JavaScript in the global scope is a terrible idea. Why is CSS any different?
12
12
13
13
Imagine if we could import the CSS that a component needs without leaking selectors into the global scope. We wouldn't need naming conventions like [BEM] to avoid naming collisions, and we could prevent accidental coupling between components by ensuring our CSS follows the same scoping rules as any JavaScript module.
14
14
15
-
Webpack allows [local scope] in CSS with [css-loader], but it's opt-in via a special `.local[identifier]` syntax.
15
+
Webpack allows [local scope] in CSS with [css-loader], but it's opt-in via a special `:local(.identifier)` syntax.
16
16
17
17
This plugin transforms standard class selectors into local identifiers so that [local scope] is the default and global styles are the exception, just like any sane module system.
18
18
@@ -75,25 +75,25 @@ Classes are dynamically generated at build time by [css-loader], so components a
throwrule.error('Global selector detected in local context. Does this selector really need to be global? If so, you need to explicitly export it into the global scope with ":global", e.g. ":global '+trimmedSelector+'"',{plugin: 'postcss-local-scope'});
22
22
}
@@ -26,7 +26,8 @@ function transformSelector(rule, selector) {
0 commit comments