@beyonk/google-fonts-webpack-plugin

中文文档
1.7.0发布于 2021/04/12ISCCommonJS近 30 天下载 3446

Google Fonts Webpack plugin

原始使用文档
文档目录4 节
  1. Install
  2. Usage
  3. Options
  4. FontObject

Google Fonts Webpack Plugin

Compatible with Webpack >= 4.14.0 and >= 5.0.0

Download Google fonts to webpack build folder using google-webfonts-helper or use CDN to integrate with html-webpack-plugin.

publish


Install

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

Usage

/webpack.config.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 */
        })
    ]
}

Options

new GoogleFontsPlugin(options: Object)
NameTypeDefaultDescription
fontsFontObject[]-Configuration generated by Fontello.com.
nameString"fonts"Module name.
filenameString"fonts.css"Css file name.
pathString"font/"Relative path to fonts directory. If path is undefined fonts are not downloaded, the css file is generated with Google hosted font files.
localBooleantrueWhether to use google-webfonts-helper API or just link to Google Fonts hosted css. If this option is set to false this plugin just adds the css url to html-webpack-plugin (if present).
noLocalInCssBooleanfalseWhether to prepend local(FontName) expression before font files in CSS file (see MDN).
formatsArray[ "eot", "woff", "woff2", "ttf", "svg" ]Font formats to download.
apiUrlString"https://google-webfonts-helper.herokuapp.com/api/fonts"google-webfonts-helper API url.

FontObject

NameTypeDefaultDescription
familyString-Font family.
variantsArray-Font variants according to google-webfonts-helper (e.g.: [ "italic", "500", "700italic" ]).
subsetsArray-Font subsets according to google-webfonts-helper (e.g.: [ "latin", "greek" ]).
formatsArray-Font formats to download. Defaults to options.formats.
displayString"swap"Font Display

版本与发布记录

@beyonk/google-fonts-webpack-plugin 共发布 9 个版本,首次发布于 2018/08/02;过去 12 个月发布了 0 个版本。

版本发布日期距今
1.7.0latest2021/04/125 年前
1.5.02020/08/136 年前
1.4.22020/07/176 年前
1.2.32019/02/237 年前
1.2.22019/02/087 年前
1.2.12018/10/168 年前

关于 @beyonk/google-fonts-webpack-plugin 的常见问题

@beyonk/google-fonts-webpack-plugin 是什么?

Google Fonts Webpack plugin

如何安装 @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 和提交记录判断。