mirror of https://github.com/vuejs/vitepress
parent
877f643b13
commit
3c736c1c95
@ -0,0 +1,29 @@
|
||||
// @ts-ignore
|
||||
import postcssPrefixSelector from 'postcss-prefix-selector'
|
||||
|
||||
export function postcssIsolateStyles(options: Options = {}) {
|
||||
if (options.enable === false) return false
|
||||
return postcssPrefixSelector({
|
||||
prefix: ':not(:where(.vp-raw, .vp-raw *))',
|
||||
includeFiles: [/base\.css/],
|
||||
transform(prefix, _selector) {
|
||||
const [selector, pseudo = ''] = _selector.split(/:\S*$/)
|
||||
return selector + prefix + pseudo
|
||||
},
|
||||
...options
|
||||
} satisfies Omit<Options, 'enable'>) as (root: any) => void
|
||||
}
|
||||
|
||||
interface Options {
|
||||
enable?: boolean
|
||||
prefix?: string
|
||||
exclude?: (string | RegExp)[]
|
||||
ignoreFiles?: (string | RegExp)[]
|
||||
includeFiles?: (string | RegExp)[]
|
||||
transform?: (
|
||||
prefix: string,
|
||||
selector: string,
|
||||
prefixedSelector: string,
|
||||
file: string
|
||||
) => string
|
||||
}
|
Loading…
Reference in new issue