- From: Carter Li <notifications@github.com>
- Date: Sat, 27 Oct 2018 09:53:39 -0700
- To: w3c/webcomponents <webcomponents@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
Received on Saturday, 27 October 2018 16:54:00 UTC
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