fix: pseudo styles being removed with postcssIsolateStyles

closes #2868
closes #2867
pull/2876/head
Divyansh Singh 1 year ago
parent 6be5a7e830
commit 21b4f8caad

@ -1,17 +1,13 @@
import postcssPrefixSelector from 'postcss-prefix-selector' import postcssPrefixSelector from 'postcss-prefix-selector'
type Options = Parameters<typeof postcssPrefixSelector>[0] & { type Options = Parameters<typeof postcssPrefixSelector>[0]
enable?: boolean
}
export function postcssIsolateStyles(_options: Options = {}) { export function postcssIsolateStyles(options: Options = {}) {
const { enable, ...options } = _options
if (enable === false) return false
return postcssPrefixSelector({ return postcssPrefixSelector({
prefix: ':not(:where(.vp-raw, .vp-raw *))', prefix: ':not(:where(.vp-raw, .vp-raw *))',
includeFiles: [/base\.css/], includeFiles: [/base\.css/],
transform(prefix, _selector) { transform(prefix, _selector) {
const [selector, pseudo = ''] = _selector.split(/:\S*$/) const [selector, pseudo = ''] = _selector.split(/(:\S*)$/)
return selector + prefix + pseudo return selector + prefix + pseudo
}, },
...options ...options

Loading…
Cancel
Save