Skip to content
This repository was archived by the owner on Jan 18, 2022. It is now read-only.

Question: Usage with vue custom element #115

Closed
oskarrough opened this issue Jul 28, 2017 · 4 comments
Closed

Question: Usage with vue custom element #115

oskarrough opened this issue Jul 28, 2017 · 4 comments

Comments

@oskarrough
Copy link

Is it possible to extract the scoped styles of a Vue app and pass them to https://github.com/karol-f/vue-custom-element? I see some options here http://vuejs.github.io/rollup-plugin-vue/#/en/2.3/?id=custom-handler but could not figure out how to pass it to this:

Vue.use(vueCustomElement)
Vue.customElement('my-component', MyComponent, {
  shadow: true,
  shadowCSS: `h1{color: blue}`
})

Related karol-f/vue-custom-element#17. Bonus info:, our styles are currently written as <style scoped> inside each .Vue component.

@oskarrough
Copy link
Author

rollup-plugin-vue already supports injecting styles with JS. They are inserted in the <head> element.

What if they were inserted inside the Vue component's root element? Then the styles would be included in the shadowDOM.

@znck
Copy link
Member

znck commented Jul 29, 2017

I'd explore this and possibilities.

@oskarrough
Copy link
Author

How would we do this? I don't have any experience with rollup plugins.

Can we prepend it to the Vue template of the root component? Does rollup have access to this anywhere?

@znck
Copy link
Member

znck commented May 2, 2018

You can use {css: false} option to convert styles to import and then use postcss-plugin-css-only to get the scoped styles.

Related #184

@znck znck closed this as completed May 2, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants