Skip to content

Commit 1b5f768

Browse files
authored
docs: only allow UnoCSS as the CSS engine (#1720)
1 parent 0c1e2bf commit 1b5f768

File tree

11 files changed

+24
-83
lines changed

11 files changed

+24
-83
lines changed

docs/addons/write-an-addon.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ An addon can contribute to the following points:
99
- Global styles (use with caution as it has more role than [themes](/themes/use))
1010
- Provide custom layouts or override the existing one
1111
- Provide custom components or override the existing one
12-
- Extend UnoCSS/Windi CSS configurations
12+
- Extend UnoCSS CSS configurations
1313
- Configure tools like Monaco and Prism
1414

1515
## Conventions

docs/custom/config-unocss.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<Environment type="node" />
44

5-
[UnoCSS](https://unocss.dev) is now the default CSS framework for Slidev since v0.42.0. UnoCSS is a fast atomic CSS engine that has full flexibility and extensibility.
5+
[UnoCSS](https://unocss.dev) is now the default CSS framework for Slidev since v0.42.0. UnoCSS is a fast atomic CSS engine that has full flexibility and extensibility. Most of the Tailwind CSS classes are supported **out-of-box**, and you can also extend it with your own configurations.
66

77
By default, Slidev enables the following presets out-of-box:
88

docs/custom/config-windicss.md

Lines changed: 0 additions & 53 deletions
This file was deleted.

docs/guide/syntax.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ console.log('Hello, World!')
2727

2828
# Page 3
2929

30-
You can directly use Windi CSS and Vue components to style and enrich your slides.
30+
You can directly use UnoCSS CSS and Vue components to style and enrich your slides.
3131

3232
<div class="p-3">
3333
<Tweet id="20" />

packages/client/setup/main.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import setupRoutes from '../setup/routes'
1313
import setups from '#slidev/setups/main'
1414

1515
import '#slidev/styles'
16-
import 'shiki-magic-move/style.css'
1716

1817
export default async function setupMain(app: App) {
1918
function setMaxHeight() {

packages/parser/src/config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ export function verifyConfig(
110110
if (themeHightlighter && config.highlighter !== themeHightlighter)
111111
warn(`Syntax highlighter "${config.highlighter}" does not supported by the theme`)
112112

113-
if (!['unocss', undefined].includes(config.css)) {
113+
if (config.css !== 'unocss') {
114114
warn(`Unsupported Atomic CSS engine "${config.css}", fallback to UnoCSS`)
115115
config.css = 'unocss'
116116
}

packages/slidev/node/cli.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -634,7 +634,7 @@ function printInfo(
634634
verifyConfig(options.data.config, options.data.themeMeta, v => console.warn(yellow(` ! ${v}`)))
635635

636636
console.log(dim(' theme ') + (options.theme ? green(options.theme) : gray('none')))
637-
console.log(dim(' css engine ') + (options.data.config.css ? blue(options.data.config.css) : gray('none')))
637+
console.log(dim(' css engine ') + blue('unocss'))
638638
console.log(dim(' entry ') + dim(path.dirname(options.entry) + path.sep) + path.basename(options.entry))
639639

640640
if (port) {

packages/slidev/node/virtual/styles.ts

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,18 +43,17 @@ export const templateStyle: VirtualModuleTemplate = {
4343
imports.push(
4444
`import "${await resolveImportUrl('@shikijs/vitepress-twoslash/style.css')}"`,
4545
`import "${resolveUrlOfClient('styles/shiki-twoslash.css')}"`,
46+
`import "${await resolveImportUrl('shiki-magic-move/style.css')}"`,
4647
)
4748
}
4849

49-
if (data.config.css === 'unocss') {
50-
imports.unshift(
51-
`import "${await resolveImportUrl('@unocss/reset/tailwind.css')}"`,
52-
'import "uno:preflights.css"',
53-
'import "uno:typography.css"',
54-
'import "uno:shortcuts.css"',
55-
)
56-
imports.push('import "uno.css"')
57-
}
50+
imports.unshift(
51+
`import "${await resolveImportUrl('@unocss/reset/tailwind.css')}"`,
52+
'import "uno:preflights.css"',
53+
'import "uno:typography.css"',
54+
'import "uno:shortcuts.css"',
55+
)
56+
imports.push('import "uno.css"')
5857

5958
return imports.join('\n')
6059
},

packages/slidev/node/vite/extendConfig.ts

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -109,15 +109,13 @@ export function createConfigPlugin(options: ResolvedSlidevOptions): Plugin {
109109
exclude: EXCLUDE_LOCAL,
110110
include: INCLUDE_LOCAL,
111111
},
112-
css: options.data.config.css === 'unocss'
113-
? {
114-
postcss: {
115-
plugins: [
116-
await import('postcss-nested').then(r => (r.default || r)()) as any,
117-
],
118-
},
119-
}
120-
: {},
112+
css: {
113+
postcss: {
114+
plugins: [
115+
await import('postcss-nested').then(r => (r.default || r)()) as any,
116+
],
117+
},
118+
},
121119
server: {
122120
fs: {
123121
strict: true,

packages/slidev/node/vite/index.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import type { ResolvedSlidevOptions, SlidevPluginOptions, SlidevServerOptions }
1212
import { loadDrawings, writeDrawings } from '../integrations/drawings'
1313
import { createConfigPlugin } from './extendConfig'
1414
import { createSlidesLoader } from './loaders'
15-
15+
import { createUnocssPlugin } from './unocss'
1616
import { createMarkdownPlugin } from './markdown'
1717
import { createVueCompilerFlagsPlugin } from './compilerFlagsVue'
1818
import { createMonacoTypesLoader } from './monacoTypes'
@@ -120,6 +120,7 @@ export async function ViteSlidevPlugin(
120120
createConfigPlugin(options),
121121
createMonacoTypesLoader(options),
122122
createVueCompilerFlagsPlugin(options),
123+
createUnocssPlugin(options, pluginOptions),
123124

124125
publicRoots.length
125126
? import('vite-plugin-static-copy').then(r => r.viteStaticCopy({
@@ -136,10 +137,6 @@ export async function ViteSlidevPlugin(
136137
build: true,
137138
}))
138139
: null,
139-
140-
config.css === 'none'
141-
? null
142-
: import('./unocss').then(r => r.createUnocssPlugin(options, pluginOptions)),
143140
]
144141

145142
return (await Promise.all(plugins))

0 commit comments

Comments
 (0)