@codecov/astro-plugin

中文文档
2.0.1发布于 2026/04/15MITTypeScriptESM + CJS近 30 天下载 7722

Official Codecov Astro Plugin

原始使用文档
文档目录6 节
  1. Installation
  2. Public Repo Example - GitHub Actions
  3. Public Repo Example - Non-GitHub Actions
  4. Private Repo Example
  5. OIDC Configuration Example
  6. More information

Codecov by Sentry logo

Codecov Astro Plugin

An Astro integration that provides bundle analysis support for Codecov.

[!NOTE] The plugin does not support code coverage, see our docs to set up coverage today!

Installation

Using npm:

npx astro add @codecov/astro-plugin

Using yarn:

yarn astro add @codecov/astro-plugin

Using pnpm:

pnpm astro add @codecov/astro-plugin

Public Repo Example - GitHub Actions

This configuration will automatically upload the bundle analysis to Codecov for public repositories. When an internal PR is created it will use the Codecov token set in your secrets, and if running from a forked PR, it will use the tokenless setting automatically. For setups not using GitHub Actions see the following example. For private repositories see the following example.

// astro.config.mjs
import { defineConfig } from "astro/config";
import { codecovAstroPlugin } from "@codecov/astro-plugin";

// https://astro.build/config
export default defineConfig({
  // other config settings
  integrations: [
    // place this after all other integrations
    codecovAstroPlugin({
      enableBundleAnalysis: true,
      bundleName: "example-astro-bundle",
      uploadToken: process.env.CODECOV_TOKEN,
      gitService: "github",
    }),
  ],
});

Public Repo Example - Non-GitHub Actions

This setup is for public repositories that are not using GitHub Actions, this configuration will automatically upload the bundle analysis to Codecov. You will need to configure the it similar to the GitHub Actions example, however you will need to provide a branch override, and ensure that it will pass the correct branch name, and with forks including the fork-owner i.e. fork-owner:branch.

// astro.config.mjs
import { defineConfig } from "astro/config";
import { codecovAstroPlugin } from "@codecov/astro-plugin";

// https://astro.build/config
export default defineConfig({
  // other config settings
  integrations: [
    // place this after all other integrations
    codecovAstroPlugin({
      enableBundleAnalysis: true,
      bundleName: "example-astro-bundle",
      uploadToken: process.env.CODECOV_TOKEN,
      gitService: "github",
      uploadOverrides: {
        branch: "<branch value>",
      },
    }),
  ],
});

Private Repo Example

This is the required way to use the plugin for private repositories. This configuration will automatically upload the bundle analysis to Codecov.

This configuration will automatically upload the bundle analysis to Codecov for public repositories. When an internal PR is created it will use the Codecov token set in your secrets, and if running from a forked PR, it will use the tokenless setting automatically. For setups not using GitHub Actions see the following example. For private repositories see the following example.

// astro.config.mjs
import { defineConfig } from "astro/config";
import { codecovAstroPlugin } from "@codecov/astro-plugin";

// https://astro.build/config
export default defineConfig({
  // other config settings
  integrations: [
    // place this after all other integrations
    codecovAstroPlugin({
      enableBundleAnalysis: true,
      bundleName: "example-astro-bundle",
      uploadToken: process.env.CODECOV_TOKEN,
    }),
  ],
});

OIDC Configuration Example

For users with OpenID Connect (OIDC) enabled, setting the uploadToken is not necessary. You can use OIDC with the oidc configuration as following.

// astro.config.mjs
import { defineConfig } from "astro/config";
import { codecovAstroPlugin } from "@codecov/astro-plugin";

// https://astro.build/config
export default defineConfig({
  // other config settings
  integrations: [
    // place this after all other integrations
    codecovAstroPlugin({
      enableBundleAnalysis: true,
      bundleName: "example-astro-bundle",
      oidc: {
        useGitHubOIDC: true,
      },
    }),
  ],
});

More information

版本与发布记录

@codecov/astro-plugin 共发布 7 个版本,首次发布于 2024/12/10;过去 12 个月发布了 2 个版本。

版本发布日期距今
2.0.1latest2026/04/156 个月前
2.0.02026/04/156 个月前
1.9.12025/05/201.5 年前
1.9.02025/02/111.7 年前
1.8.02025/01/201.8 年前
1.7.02024/12/311.9 年前

关于 @codecov/astro-plugin 的常见问题

@codecov/astro-plugin 是什么?

Official Codecov Astro Plugin

如何安装 @codecov/astro-plugin?

在项目目录运行 npm install @codecov/astro-plugin,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:astro(4.x || 5.x)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@codecov/astro-plugin 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@codecov/astro-plugin 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@codecov/astro-plugin 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=20.0.0。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@codecov/astro-plugin 可以商用吗?

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

@codecov/astro-plugin 的下载量有多少?

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

@codecov/astro-plugin 还在维护吗?

最新版本 2.0.1 发布于 2026/04/15(6 个月前);至今共发布 7 个版本,其中过去 12 个月发布了 2 个;首次发布于 2024/12/10。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。