Skip to main content

命令行接口

SvelteKit 项目使用 Vite,这意味着你将主要使用其 CLI(尽管通过 npm run dev/build/preview 脚本):

¥SvelteKit projects use Vite, meaning you’ll mostly use its CLI (albeit via npm run dev/build/preview scripts):

  • vite dev — 启动开发服务器

    ¥vite dev — start a development server

  • vite build — 构建应用的生产版本

    ¥vite build — build a production version of your app

  • vite preview — 在本地运行生产版本

    ¥vite preview — run the production version locally

但是 SvelteKit 包含自己的 CLI 来初始化你的项目:

¥However SvelteKit includes its own CLI for initialising your project:

svelte-kit sync

svelte-kit sync 为你的项目创建 tsconfig.json 和所有生成的类型(你可以在路由文件中将其作为 ./$types 导入)。当你创建新项目时,它会被列为 prepare 脚本,并将作为 npm 生命周期的一部分自动运行,因此你通常不必运行此命令。

¥svelte-kit sync creates the tsconfig.json and all generated types (which you can import as ./$types inside routing files) for your project. When you create a new project, it is listed as the prepare script and will be run automatically as part of the npm lifecycle, so you should not ordinarily have to run this command.

上一页 下一页