Skip to content

Commit

Permalink
feat: add preflights and safelist to shadow-dom mode (#1110)
Browse files Browse the repository at this point in the history
  • Loading branch information
userquin committed Jun 18, 2022
1 parent 6674878 commit d6b841e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
6 changes: 6 additions & 0 deletions examples/vite-lit/src/my-element.ts
Expand Up @@ -46,6 +46,12 @@ export class MyElement extends LitElement {
<br />
${this.span ? html` <div class="bg-red-400">BG Color should change</div>` : html` <div>BG Color should change</div>`}
<br />
<br />
<button class="shadow-2xl bg-white p-4 rounded-lg border-none" part="button">
prefligths: shadow-2xl
</button>
<br />
<br />
<button class="bg-red-100" @click=${this._onClick} part="button">
Click Count: ${this.count}
</button>
Expand Down
5 changes: 4 additions & 1 deletion packages/vite/src/modes/shadow-dom.ts
Expand Up @@ -48,7 +48,10 @@ export function ShadowDomModuleModePlugin({ uno }: UnocssPluginContext): Plugin
return code

// eslint-disable-next-line prefer-const
let { css, matched } = await uno.generate(code, { preflights: false })
let { css, matched } = await uno.generate(code, {
preflights: true,
safelist: true,
})

if (css && matched) {
// filter only parts from the result reported from the generator
Expand Down

0 comments on commit d6b841e

Please sign in to comment.