Build .css.ts/.css.js modules as css assets.
npm i -D esbuild-plugin-esmcss
Build file
import { build } from 'esbuild'
import esmcss from 'esbuild-plugin-esmcss'
await build({
entryPoints: [/* source code entry point */],
plugins: [esmcss()]
})
Component file
import './component.css.js'
export function html_() {
return `
<!DOCTYPE html>
<html>
<head>
link_({ rel: 'stylesheet', type: 'text/css', href })
<link rel="stylesheet" type="text/css" href="/path/to/cssBundle.css">
</head>
<body>
<div class="my_component">Hello!</div>
</body>
</html>
`.trim()
}
component.css.ts
export default ()=>`
.my_component {
color: green;
}
`