mirror of https://github.com/vuejs/vitepress
commit
013160ee67
@ -0,0 +1,44 @@
|
|||||||
|
import {
|
||||||
|
postcssIsolateStyles,
|
||||||
|
splitSelectorPseudo
|
||||||
|
} from 'node/postcss/isolateStyles'
|
||||||
|
|
||||||
|
// helper to run plugin transform on selector
|
||||||
|
function apply(
|
||||||
|
prefixPlugin: ReturnType<typeof postcssIsolateStyles>,
|
||||||
|
selector: string
|
||||||
|
) {
|
||||||
|
// `prepare` is available on the runtime plugin but missing from the types, thus cast to `any`
|
||||||
|
const { Rule } = (prefixPlugin as any).prepare({
|
||||||
|
root: { source: { input: { file: 'foo/base.css' } } }
|
||||||
|
})
|
||||||
|
const rule = { selectors: [selector] }
|
||||||
|
Rule(rule, { result: {} })
|
||||||
|
return rule.selectors[0]
|
||||||
|
}
|
||||||
|
|
||||||
|
describe('node/postcss/isolateStyles', () => {
|
||||||
|
const plugin = postcssIsolateStyles()
|
||||||
|
|
||||||
|
test('splitSelectorPseudo skips escaped colon', () => {
|
||||||
|
const input = '.foo\\:bar'
|
||||||
|
const [selector, pseudo] = splitSelectorPseudo(input)
|
||||||
|
expect(selector).toBe(input)
|
||||||
|
expect(pseudo).toBe('')
|
||||||
|
})
|
||||||
|
|
||||||
|
test('splitSelectorPseudo splits on pseudo selectors', () => {
|
||||||
|
const input = '.button:hover'
|
||||||
|
const [selector, pseudo] = splitSelectorPseudo(input)
|
||||||
|
expect(selector).toBe('.button')
|
||||||
|
expect(pseudo).toBe(':hover')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('postcssIsolateStyles inserts :not(...) in the right place', () => {
|
||||||
|
const input = '.disabled\\:opacity-50:disabled'
|
||||||
|
const result = apply(plugin, input)
|
||||||
|
expect(result).toBe(
|
||||||
|
'.disabled\\:opacity-50:not(:where(.vp-raw, .vp-raw *)):disabled'
|
||||||
|
)
|
||||||
|
})
|
||||||
|
})
|
@ -1,2 +1,16 @@
|
|||||||
#!/usr/bin/env node
|
#!/usr/bin/env node
|
||||||
|
// @ts-check
|
||||||
|
|
||||||
|
import module from 'node:module'
|
||||||
|
|
||||||
|
// https://github.com/vitejs/vite/blob/6c8a5a27e645a182f5b03a4ed6aa726eab85993f/packages/vite/bin/vite.js#L48-L63
|
||||||
|
try {
|
||||||
|
module.enableCompileCache?.()
|
||||||
|
setTimeout(() => {
|
||||||
|
try {
|
||||||
|
module.flushCompileCache?.()
|
||||||
|
} catch {}
|
||||||
|
}, 10 * 1000).unref()
|
||||||
|
} catch {}
|
||||||
|
|
||||||
import('../dist/node/cli.js')
|
import('../dist/node/cli.js')
|
||||||
|
@ -1,22 +0,0 @@
|
|||||||
import { defineConfig } from 'vitepress'
|
|
||||||
import { shared } from './shared'
|
|
||||||
import { en } from './en'
|
|
||||||
import { zh } from './zh'
|
|
||||||
import { pt } from './pt'
|
|
||||||
import { ru } from './ru'
|
|
||||||
import { es } from './es'
|
|
||||||
import { ko } from './ko'
|
|
||||||
import { fa } from './fa'
|
|
||||||
|
|
||||||
export default defineConfig({
|
|
||||||
...shared,
|
|
||||||
locales: {
|
|
||||||
root: { label: 'English', ...en },
|
|
||||||
zh: { label: '简体中文', ...zh },
|
|
||||||
pt: { label: 'Português', ...pt },
|
|
||||||
ru: { label: 'Русский', ...ru },
|
|
||||||
es: { label: 'Español', ...es },
|
|
||||||
ko: { label: '한국어', ...ko },
|
|
||||||
fa: { label: 'فارسی', ...fa }
|
|
||||||
}
|
|
||||||
})
|
|
@ -1,10 +1,10 @@
|
|||||||
import { createRequire } from 'module'
|
import { createRequire } from 'module'
|
||||||
import { defineConfig, type DefaultTheme } from 'vitepress'
|
import { defineAdditionalConfig, type DefaultTheme } from 'vitepress'
|
||||||
|
|
||||||
const require = createRequire(import.meta.url)
|
const require = createRequire(import.meta.url)
|
||||||
const pkg = require('vitepress/package.json')
|
const pkg = require('vitepress/package.json')
|
||||||
|
|
||||||
export const en = defineConfig({
|
export default defineAdditionalConfig({
|
||||||
lang: 'en-US',
|
lang: 'en-US',
|
||||||
description: 'Vite & Vue powered static site generator.',
|
description: 'Vite & Vue powered static site generator.',
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue