You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The linked section explains how to apply the styles from an SFC inside the shadow root of the custom element. It states that by changing the file extension to .ce.vue, the file should export an object with a .styles property which contains the styles for the SFC.
When I try this approach with unplugin-vue and esbuild, the .styles property always contains [ {} ] (An array containing an empty object). And because of this, Vue does not inject the right styles inside the shadow DOM of the element.
I can get the right styles by setting shadowRoot: false on the element and importing the .css file generated by esbuild in my HTML file. However, this solution does not work for our purposes as we absolutely require shadow root for our components. Without shadow root we cannot use <slot> in our custom components.
On this line&inline is added to the import statement that imports CSS from the SFC, with the intention of importing it as a raw string. While Vite supports this, ES Build doesn't. And I don't think there's a way to make ES Build import that as a raw string, at least not out of the box. See https://stackoverflow.com/questions/76206575/esbuild-import-css-as-a-string
Describe the bug
Hi, I'm trying to create custom elements (web components) using Vue, following this example from the Vue website.
The linked section explains how to apply the styles from an SFC inside the shadow root of the custom element. It states that by changing the file extension to
.ce.vue
, the file should export an object with a.styles
property which contains the styles for the SFC.See my attempt here: https://github.com/sytzez/vue-ce-test/blob/master/src/index.js
When I try this approach with
unplugin-vue
andesbuild
, the.styles
property always contains[ {} ]
(An array containing an empty object). And because of this, Vue does not inject the right styles inside the shadow DOM of the element.I can get the right styles by setting
shadowRoot: false
on the element and importing the.css
file generated byesbuild
in my HTML file. However, this solution does not work for our purposes as we absolutely require shadow root for our components. Without shadow root we cannot use<slot>
in our custom components.Reproduction
https://github.com/sytzez/vue-ce-test
System Info
Used Package Manager
npm
Validations
The text was updated successfully, but these errors were encountered: