返回 slidev
cli.md
根目录 / docs / builtin / cli.md
1 # Slidev CLI
2
3 `@slidev/cli` exposes a binary called `slidev` that you can use to develop, build, and export your slides.
4
5 ## Prerequisites
6
7 To use the CLI, you can either install `@slidev/cli` globally or install it locally in your Node.js project. If you created your project with `npm init slidev`, the CLI is already installed locally.
8
9 ::: warning
10 Usually `npx slidev` is not supported because the package name is actually `@slidev/cli`.
11 :::
12
13 The CLI options of the commands obey the following conventions:
14
15 - the value of the option can be passed after a space or a `=` character:
16
17 Example: `slidev --port 8080` is equivalent to `slidev --port=8080`
18
19 - `true` can be omitted for boolean options:
20
21 Example: `slidev --open` is equivalent to `slidev --open true`
22
23 ::: info
24
25 If you use npm, please don't forget to add `--` before the options to pass them to Slidev:
26
27 ```bash
28 npm run slidev -- --remote --port 8080 --open
29 ```
30
31 :::
32
33 ## `slidev [entry]` {#dev}
34
35 Start a local server for Slidev.
36
37 - `[entry]` (`string`, default: `slides.md`): path to the markdown file containing your slides.
38
39 Options:
40
41 - `--port`, `-p` (`number`, default: `3030`): port number.
42 - `--base` (`string`, default: `/`): base URL (see https://vitejs.dev/config/shared-options.html#base).
43 - `--open`, `-o` (`boolean`, default: `false`): open in the browser.
44 - `--remote [password]` (`string`): listen to the public host and enable remote control, if a value is passed then the presenter mode is private and only accessible by passing the given password in the URL query `password` parameter.
45 - `--bind` (`string`, default: `0.0.0.0`): specify which IP addresses the server should listen on in the remote mode.
46 - `--log` (`'error', 'warn', 'info', 'silent'`, default: `'warn'`): Log level.
47 - `--force`, `-f` (`boolean`, default: `false`): force the optimizer to ignore the cache and re-bundle.
48 - `--theme`, `-t` (`string`): override theme.
49
50 ## `slidev build [entry]` {#build}
51
52 Build a hostable SPA. See <LinkInline link="guide/hosting" /> for more details.
53
54 - `[entry]` (`string`, default: `slides.md`): path to the slides markdown file.
55
56 Options:
57
58 - `--out`, `-o` (`string`, default: `dist`): output directory
59 - `--base` (`string`, default: `/`): base URL (see https://vitejs.dev/config/shared-options.html#base)
60 - `--download` (`boolean`, default: `false`): allow the download of the slides as a PDF inside the SPA
61 - `--theme`, `-t` (`string`): override theme
62 - `--without-notes` (`boolean`, default: `false`): exclude speaker notes from the SPA
63
64 ## `slidev export [...entry]` {#export}
65
66 Export slides to PDF (or other format). See <LinkInline link="guide/exporting" /> for more details.
67
68 - `[entry]` (`string`, default: `slides.md`): path to the slides markdown entry.
69
70 Options:
71
72 - `--output` (`string`, default: use `exportFilename` (see https://sli.dev/custom/#frontmatter-configures) or use `[entry]-export`): path to the output.
73 - `--format` (`'pdf', 'png', 'pptx', 'md'`, default: `'pdf'`): output format.
74 - `--timeout` (`number`, default: `30000`): timeout for rendering the print page (see https://playwright.dev/docs/api/class-page#page-goto).
75 - `--range` (`string`): page ranges to export (example: `'1,4-5,6'`).
76 - `--dark` (`boolean`, default: `false`): export as dark theme.
77 - `--with-clicks`, `-c` (`boolean`, default: `false`): export pages for every click animation (see https://sli.dev/guide/animations.html#click-animation).
78 - `--theme`, `-t` (`string`): override theme.
79 - `--omit-background` (`boolean`, default: `false`): remove the default browser background
80
81 ## `slidev format [entry]` {#format}
82
83 Format the markdown file. Note that this won't format the content of the slides, only the organization of the markdown file.
84
85 - `[entry]` (`string`, default: `slides.md`): path to the slides markdown entry.
86
87 ## `slidev mcp [entry]` {#mcp}
88
89 Start an MCP (Model Context Protocol) server over stdio for AI agents to inspect and edit the slides. See <LinkInline link="features/mcp" />.
90
91 - `[entry]` (`string`, default: `slides.md`): path to the slides markdown entry.
92
93 ## `slidev theme [subcommand]` {#theme}
94
95 Theme-related operations.
96
97 Subcommands:
98
99 - `eject [entry]`: Eject the current theme into the local file system. See <LinkInline link="features/eject-theme" />.
100 - `[entry]` (`string`, default: `slides.md`): path to the slides markdown entry.
101 - Options:
102 - `--dir` (`string`, default: `theme`): the output dir.
103 - `--theme`, `-t` (`string`): override theme.
104
104 lines MARKDOWN