umbopepato / rollup-plugin-postcss-lit

Rollup plugin to load PostCSSed stylesheets in LitElement components
MIT License
34 stars 6 forks source link

Invalid CSS produced with Vite 3 when using a base path #53

Open Artur- opened 2 years ago

Artur- commented 2 years ago

The original issue was created in https://github.com/vitejs/vite/issues/9694

With Vite 3 the CSS in JS can be of the type

const a = 'foo '+someJS + 'bar';

in practice it is used for calculating relative URLs

When the string is wrapped by this plugin, it is changed to a format where the JS is no longer executed and you end up with something like this in the final CSS

@font-face{font-family:Line Awesome Brands;font-style:normal;font-weight:400;font-display:auto;src:url("+new URL('la-brands-400.c0e32387.eot', import.meta.url).href+");

Not sure if the escaping can be fixed or worked around here or if this needs to be fixed in Vite