|
|
@ -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
|
|
|
|