-
With vite as the build tool, what is the current 'best practice' way to write styles for lit components in an external stylesheet? The documentation discourages this practice but a tagged literal for CSS is a no go currently; devs want their autocomplete — I want my autocomplete! In addition we would like to see a file save of the external CSS/Sass file cause the browser to be updated with the changes. Can this be achieved? Working examples seem hard to come by. Using lit 2.7.6, vite 4.4.4 with an option to use Sass or vanilla CSS if that makes things easier? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 7 replies
-
The Material Web Components authors styles with scss and compiles it to css before using a script to convert to .ts files wrapped with The ultimate answer probably is CSS module scripts so you'd be able to directly import css files as modules into your component code and pass it in to Since you're using Vite now, you technically can import css as string with |
Beta Was this translation helpful? Give feedback.
The
?inline
import for Vite provides a string as the default export so you'd want to pass that string directly into theunsafeCSS()
call. If you do an array, it'll try to turn it into a string which means it'll get joined with a comma separator between them.So either
or
would be cleaner, I think.