# @11ty/eleventy-plugin-vite 中文文档

规范地址：https://npmcn.com/package/%4011ty/eleventy-plugin-vite/

版本：8\.0\.0
npm 元数据更新时间：2026-05-02T05:53:16.587Z
中文译文更新时间：2026-11-06T00:36:32.228Z
软件包许可：MIT

本文由上游 README 翻译，可能存在偏差，请结合原文核对 API、命令与配置。版权与许可归原作者所有。

原始 npm 页面：https://www.npmjs.com/package/%4011ty/eleventy-plugin-vite
原文对照：https://npmcn.com/package/%4011ty/eleventy-plugin-vite/?lang=original
项目主页：https://github.com/11ty/eleventy-plugin-vite/
源码仓库：https://github.com/11ty/eleventy-plugin-vite

## 关键信息（来自 npm 元数据）

- 包体积（解压后）：12.7 kB，4 个文件
- 模块格式：ES Module
- TypeScript 类型：未声明
- Node.js 要求：^20\.19\.0 \|\| \>=22\.12\.0
- 运行依赖：2 个
- 首次发布：2022-03-17T18:22:06.079Z
- 最新版本发布：2026-05-02T05:53:16.259Z
- 近 30 天下载量：8151（2026-10-04 至 2026-11-02，npm 官方下载统计）
- 已发布版本数：27（近 12 个月 4 个）

## 中文简介

一个将 Vite 用作开发服务器并运行 Vite 的插件来完成您的 十一 构建 .

## 安装

```sh
npm install @11ty/eleventy-plugin-vite
```

也可以使用：`pnpm add @11ty/eleventy-plugin-vite`、`yarn add @11ty/eleventy-plugin-vite`、`bun add @11ty/eleventy-plugin-vite`

## README

![11ty Logo](https://www.11ty.dev/img/logo-github.svg)  ![Vite logo](https://v1.image.11ty.dev/https%3A%2F%2Fvitejs.dev%2Flogo.svg/png/200x200/)

# 十一号插座 - 视频

要使用的插件 [维特](https://vitejs.dev/) 和十一号.

此插件 :

-   在 十一 Dev 服务器中将 Vite 作为中件运行( 尝试 十一 ) `--incremental`(中文(简体) )
-   运行 Vite 构建到后处理您的十一构建输出

## 十一楼房务

-   请坐 [十一号在吉打](https://github.com/11ty/eleventy/)来啊!
-   跟着我们去马斯多登 [@eleventy@fosstodon.org (西班牙语)](https://fosstodon.org/@eleventy) 或微博 [@ eleven ty (帮助)](https://twitter.com/eleven_ty)
-   加入我们 [解析器](https://www.11ty.dev/blog/discord/)
-   支助 [开放集体11号](https://opencollective.com/11ty)
-   [晚上11点](https://www.npmjs.com/org/11ty)
-   [GitHub上11号](https://github.com/11ty)

[![npm Version](https://img.shields.io/npm/v/@11ty/eleventy-plugin-vite.svg?style=for-the-badge)](https://www.npmjs.com/package/@11ty/eleventy-plugin-vite)

## 安装

```
npm install @11ty/eleventy-plugin-vite@alpha --save-dev
```

### 无害环境管理 `.eleventy.js` 配置

```js
import EleventyVitePlugin from "@11ty/eleventy-plugin-vite";

export default function (eleventyConfig) {
    eleventyConfig.addPlugin(EleventyVitePlugin);
}
```

### 常见JS `.eleventy.js` 配置

> \[注\] 因此,这个插件是用无害环境管理编写的 `require` 这是不可能的。 如果您的. eleventy.js 配置使用 CommunityJS, 请将其合成并创建动态导入如下 .

```js
module.exports = async function (eleventyConfig) {
    const EleventyPluginVite = (await import("@11ty/eleventy-plugin-vite")).default;

    eleventyConfig.addPlugin(EleventyPluginVite);
};
```

更多信息,请查看有关无害环境管理与普通JS的更多信息 [十一个文件](https://www.11ty.dev/docs/cjs-esm/)。 。 。 .

### 选项

这是插件的默认选项 。 除非你想改变它们,否则就不必具体指明它们.

```js
import EleventyVitePlugin from "@11ty/eleventy-plugin-vite";

export default function (eleventyConfig) {
    eleventyConfig.addPlugin(EleventyVitePlugin, {
        // Default name of the temp folder
        tempFolderName: ".11ty-vite",

        // Eleventy Dev Server Options
        serverOptions: {
            module: "@11ty/eleventy-dev-server",
            domDiff: false,
        },

        // Vite Config
        viteOptions: {
            clearScreen: false,
            appType: "mpa",
            server: {
                middlewareMode: true,
            },
            build: {
                emptyOutDir: true,
                rolldownOptions: {
                    input: {
                        // HTML entry points will be injected automatically
                        // Custom input will be merged
                    },
                },
            },
            resolve: {
                alias: {
                    // Allow references to `node_modules` directly for bundling.
                    "/node_modules": path.resolve(".", "node_modules"),
                    // Note that bare module specifiers are also supported
                },
            },
        },
    });
}
```

查看 [完整 Vite 配置选项列表](https://vitejs.dev/config/)自定义 vite 选项将和默认合并.

## 相关项目

-   [`eleventy-plus-vite`](https://github.com/matthiasott/eleventy-plus-vite) 由 @ matthiasott: 使用此插件的启动模板
-   目前未保存的:
    -   [`slinkity`](https://slinkity.dev/) 由@Holben888所著:与Vite更深入更全面的融合! 提供部分水分,并且可以使用简码来使框架组件在"十一"中成形!
    -   [`vite-plugin-eleventy`](https://www.npmjs.com/package/vite-plugin-eleventy) 由 @ Snuugug: 使用十一号作为维特的中间软件(而不是这里使用的处理后方法)

## 常见问题

### @11ty/eleventy-plugin-vite 是什么？

一个将 Vite 用作开发服务器并运行 Vite 的插件来完成您的 十一 构建 \.

### 如何安装 @11ty/eleventy-plugin-vite？

在项目目录运行 npm install @11ty/eleventy-plugin-vite，或使用 pnpm add / yarn add / bun add。

### @11ty/eleventy-plugin-vite 支持 TypeScript 吗？

该包的 package\.json 没有声明类型入口。需要类型提示时，可以在 npm 上查找社区维护的 @types/11ty\_\_eleventy-plugin-vite 是否存在。

### @11ty/eleventy-plugin-vite 支持 ESM 还是 CommonJS？

以 ES Module 形式发布，推荐使用 import 引入。在 CommonJS 项目中，Node\.js 20\.19\+ / 22\.12\+ 可以直接 require\(\) 不含顶层 await 的 ES Module，更早的版本需要改用动态 import\(\)。

### @11ty/eleventy-plugin-vite 需要什么版本的 Node\.js？

package\.json 的 engines 字段要求 Node\.js ^20\.19\.0 \|\| \>=22\.12\.0。版本不符时 npm 默认只给出警告，开启 engine-strict 后会拒绝安装。

### @11ty/eleventy-plugin-vite 可以商用吗？

@11ty/eleventy-plugin-vite 使用 MIT 许可。宽松许可：允许商业使用、修改和再分发，通常只需在分发时保留原版权与许可声明。以上为概括，不构成法律意见，请以许可原文为准。

### @11ty/eleventy-plugin-vite 的下载量有多少？

根据 npm 官方下载统计，@11ty/eleventy-plugin-vite 在 2026/10/04 – 2026/11/02 这 30 天内被下载 8,151 次，日均约 272 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入，适合横向比较热度，不能直接等同于使用人数。

### @11ty/eleventy-plugin-vite 还在维护吗？

最新版本 8\.0\.0 发布于 2026/05/02（6 个月前）；至今共发布 27 个版本，其中过去 12 个月发布了 4 个；首次发布于 2022/03/18。发布频率只是参考信号：功能稳定的工具可能很少需要更新，建议结合源码仓库的 issue 和提交记录判断。

