# @beyonk/google-fonts-webpack-plugin 中文文档

规范地址：https://npmcn.com/package/%40beyonk/google-fonts-webpack-plugin/

版本：1\.7\.0
npm 元数据更新时间：2026-08-24T12:21:10.932Z
中文译文更新时间：2026-11-08T00:42:06.700Z
软件包许可：ISC

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

原始 npm 页面：https://www.npmjs.com/package/%40beyonk/google-fonts-webpack-plugin
原文对照：https://npmcn.com/package/%40beyonk/google-fonts-webpack-plugin/?lang=original
项目主页：https://github.com/beyonk-adventures/google-fonts-webpack-plugin
源码仓库：https://github.com/beyonk-adventures/google-fonts-webpack-plugin

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

- 包体积（解压后）：25.2 kB，11 个文件
- 模块格式：CommonJS
- TypeScript 类型：未声明
- 运行依赖：5 个
- peer 依赖：webpack \>=4\.14\.0
- 首次发布：2018-08-02T14:00:51.374Z
- 最新版本发布：2021-04-12T08:28:12.479Z
- 近 30 天下载量：3446（2026-10-08 至 2026-11-06，npm 官方下载统计）
- 已发布版本数：9（近 12 个月 0 个）

## 中文简介

谷歌字体Webpack 插件

## 安装

```sh
npm install @beyonk/google-fonts-webpack-plugin
```

也可以使用：`pnpm add @beyonk/google-fonts-webpack-plugin`、`yarn add @beyonk/google-fonts-webpack-plugin`、`bun add @beyonk/google-fonts-webpack-plugin`

## README

# 谷歌字体 Webpack 插件

_与Webpack相兼容 QQ 4.14.0 和 5.0.0_

下载 Google 字体到使用 Webpack 构建文件夹 [google-webfonts-帮助器](https://github.com/majodev/google-webfonts-helper) 或使用 CDN 与 [html-webpack-插件](https://github.com/jantimon/html-webpack-plugin)。 。 。 .

![publish](https://github.com/beyonk-adventures/google-fonts-webpack-plugin/workflows/publish/badge.svg)

* * *

## 安装

```bash
npm install @beyonk/google-fonts-webpack-plugin
```

## 使用量

`/webpack.config.js`

```js
const GoogleFontsPlugin = require("@beyonk/google-fonts-webpack-plugin")

module.exports = {
    "entry": "index.js",
    /* ... */
    plugins: [
        new GoogleFontsPlugin({
            fonts: [
                { family: "Source Sans Pro" },
                { family: "Roboto", variants: [ "400", "700italic" ], display: "block" }
            ]
            /* ...options */
        })
    ]
}
```

## 选项

```js
new GoogleFontsPlugin(options: Object)
```

| 名称 | 类型 | 默认 | 说明 |
| --- | --- | --- | --- |
| 字体 | `FontObject[]` | \- 说吧 | 生成的配置 [Fontello.com (英语)](https://fontello.com/)。 。 。 . |
| 名称 | `String` | `"fonts"` | 模块名称. |
| 文件名 | `String` | `"fonts.css"` | Css文件名称. |
| 路径 | `String` | `"font/"` | 字体目录的相对路径 。 如果路径是 `undefined` 字体不下载,cs文件与谷歌主机字体文件生成. |
| 当地 | `Boolean` | `true` | 是否使用google-webfonts-helper API,还是仅仅链接到Google Fonts hosted css. 如果设置此选项为虚假, 此插件只是将 cs url 添加到 html-webpack- plugin (如果存在) 中 . |
| 无本地目录 | `Boolean` | `false` | 是否预付 `local(FontName)` cSS 文件中字体文件前的表达式( E)[见 MDN](https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/src)) (中文(简体) ). |
| 格式 | `Array` | `[ "eot", "woff", "woff2", "ttf", "svg" ]` | 要下载的字体格式 . |
| 阿皮尔 | `String` | `"https://google-webfonts-helper.herokuapp.com/api/fonts"` | google-webfonts-helper API url. 互联网档案馆的存檔,存档日期2013-12-22. |

### 字体对象

| 名称 | 类型 | 默认 | 说明 |
| --- | --- | --- | --- |
| 家属 | `String` | \- 说吧 | 字体出家人来. |
| 变体 | `Array` | \- 说吧 | 根据google-webfonts-helper(例如: `[ "italic", "500", "700italic" ]`) (中文(简体) ). |
| 子集 | `Array` | \- 说吧 | 根据google-webfonts-helper(例如: `[ "latin", "greek" ]`) (中文(简体) ). |
| 格式 | `Array` | \- 说吧 | 要下载的字体格式 。 默认为 `options.formats`。 。 。 . |
| 显示 | `String` | "扫地" | 字体显示 |

## 常见问题

### @beyonk/google-fonts-webpack-plugin 是什么？

谷歌字体Webpack 插件

### 如何安装 @beyonk/google-fonts-webpack-plugin？

在项目目录运行 npm install @beyonk/google-fonts-webpack-plugin，或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖：webpack（\>=4\.14\.0）。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖，Yarn 需要手动安装。

### @beyonk/google-fonts-webpack-plugin 支持 TypeScript 吗？

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

### @beyonk/google-fonts-webpack-plugin 支持 ESM 还是 CommonJS？

以 CommonJS 形式发布，可以直接 require\(\)；在 ES Module 项目中也可以用 import 引入（Node\.js 会把 module\.exports 作为默认导出）。

### @beyonk/google-fonts-webpack-plugin 可以商用吗？

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

### @beyonk/google-fonts-webpack-plugin 的下载量有多少？

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

### @beyonk/google-fonts-webpack-plugin 还在维护吗？

最新版本 1\.7\.0 发布于 2021/04/12（5 年前）；至今共发布 9 个版本，其中过去 12 个月发布了 0 个；首次发布于 2018/08/02。发布频率只是参考信号：功能稳定的工具可能很少需要更新，建议结合源码仓库的 issue 和提交记录判断。

