Skip to content

Instantly share code, notes, and snippets.

@kdepp
Created August 4, 2019 08:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kdepp/dcee792229a4359896f7498e3075f588 to your computer and use it in GitHub Desktop.
Save kdepp/dcee792229a4359896f7498e3075f588 to your computer and use it in GitHub Desktop.
Apply styles from vue files in shadow DOM
// Set shadowRoot in root Vue options
new Vue({
el: $root,
shadowRoot: yourShadowRoot,
components: { App },
render: (h: any) => h('App')
} as any)
// Set `shadowMode` in options of both vue-loader and vue-style-loader
config = {
module: {
rules: [
{
test: /\.vue$/,
loader: 'vue-loader',
options: {
shadowMode: true
}
},
{
test: /\.scss$/,
use: [
{ loader: 'vue-style-loader', options: { shadowMode: true } },
'css-loader',
'postcss-loader',
'sass-loader'
]
},
]
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment