Created
August 4, 2019 08:37
-
-
Save kdepp/dcee792229a4359896f7498e3075f588 to your computer and use it in GitHub Desktop.
Apply styles from vue files in shadow DOM
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Set shadowRoot in root Vue options | |
new Vue({ | |
el: $root, | |
shadowRoot: yourShadowRoot, | |
components: { App }, | |
render: (h: any) => h('App') | |
} as any) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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