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

I didn't read all the replies above, but for

```js
import styles from './styles.css';
```

it can be easily implemented by server side, because browsers only recognize file types using its `Content-Type` ( aka MIME ) regardless of its file extension.

I did this before:

```typescript
const handleTypes = {
  css(content: string, request: http.ServerRequest, response: http.ServerResponse) {
    if (request.headers.accept.startsWith('text/css')) {
      // <link rel="stylesheet" href="/path/to/file.css" />
      response.writeHead(200, { 'Content-Type': 'text/css' });
      return content;
    }
    // import '/path/to/file.css';
    response.writeHead(200, { 'Content-Type': 'application/javascript' });
    return 'document.head.insertAdjacentHTML("beforeEnd", `<style>' + content + '</style>`)';
  },
}
```

-- 
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-433636853

Received on Saturday, 27 October 2018 16:54:00 UTC