Re: [w3c/webcomponents] CSS Modules (#759)

To clarify that this would be useful for non-Shadow DOM use cases, especially for those who aren't familiar with the Constructible StyleSheet Objects proposal, here's how you would implement the side-effectful style of loading common today:

```js
import styles from './styles.css';
document.moreStyleSheets.push(styles);
```

Modules that currently use CSS loaders that write to global styles would just have to add the `document.moreStyleSheets.push(styles)` call.

Loaders that modify selectors could be emulated with a call to mutate the stylesheet:

```js
import styles from './styles.css';
import 'styleScoper' from 'x-style-scoper';

// extract original class names, and rewrite class names in the StyleSheet
const classNames = styleScoper(styles);
document.moreStyleSheets.push(styles);

// Use the rewritten class names
`<div ${classNames.exampleClass}}></div>`
```

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/w3c/webcomponents/issues/759#issuecomment-411622898

Received on Thursday, 9 August 2018 03:14:24 UTC