编码维特插件
一个为Codecov提供捆绑分析支持的Vite插件.
[注] 插件不支持代码覆盖, 请见 our 文档 今天就开始报道!
安装
使用 npm :
npm install @codecov/vite-plugin --save-dev
使用线条 :
yarn add @codecov/vite-plugin --dev
使用 pnpm :
pnpm add @codecov/vite-plugin --save-dev
公共 Repo 示例 - GitHub 动作
此配置将自动将捆绑分析上传到 Codecov 用于公共寄存器. 当内部的 PR 创建时, 它会使用在您的秘密中设置的 Codecov 令牌, 如果运行从一个被预留的 PR 中, 它会自动使用无令牌设置 。 对于不使用 GitHub 动作的设置,请参见以下 实例。关于私人储存库,请参见: 实例。 。 。 .
// vite.config.js
import { defineConfig } from "vite";
import { codecovVitePlugin } from "@codecov/vite-plugin";
export default defineConfig({
plugins: [
// Put the Codecov vite plugin after all other plugins
codecovVitePlugin({
enableBundleAnalysis: true,
bundleName: "example-vite-bundle",
uploadToken: process.env.CODECOV_TOKEN,
gitService: "github",
}),
],
});
公共 Repo 示例 - 非 GitHub 动作
此设置适用于没有使用 GitHub 动作的公有寄存器, 此配置将自动上传捆绑分析到 Codecov 。 您需要配置类似于 GitHub 动作示例的功能, 然而您需要提供分支覆盖, 并确保它能通过正确的分支名称, 并使用包括分叉所有者在内的分叉 . fork-owner:branch。 。 。 .
// vite.config.js
import { defineConfig } from "vite";
import { codecovVitePlugin } from "@codecov/vite-plugin";
export default defineConfig({
plugins: [
// Put the Codecov vite plugin after all other plugins
codecovVitePlugin({
enableBundleAnalysis: true,
bundleName: "example-vite-bundle",
uploadToken: process.env.CODECOV_TOKEN,
gitService: "github",
uploadOverrides: {
branch: "<branch value>",
},
}),
],
});
私人 Repo 示例
这是私人寄存器使用插件的必要方式 。 此配置将自动上传捆绑分析到 Codecov.
此配置将自动将捆绑分析上传到 Codecov 用于公共寄存器. 当内部的 PR 创建时, 它会使用在您的秘密中设置的 Codecov 令牌, 如果运行从一个被预留的 PR 中, 它会自动使用无令牌设置 。 对于不使用 GitHub 动作的设置,请参见以下 实例。关于私人储存库,请参见: 实例。 。 。 .
// vite.config.js
import { defineConfig } from "vite";
import { codecovVitePlugin } from "@codecov/vite-plugin";
export default defineConfig({
plugins: [
// Put the Codecov vite plugin after all other plugins
codecovVitePlugin({
enableBundleAnalysis: true,
bundleName: "example-vite-bundle",
uploadToken: process.env.CODECOV_TOKEN,
}),
],
});
OIDC 配置示例
用户 启用 OpenID 连接( OIDC),设置 uploadToken 没有必要。 您可以使用 OIDC 与 oidc 配置如下.
// vite.config.js
import { defineConfig } from "vite";
import { codecovVitePlugin } from "@codecov/vite-plugin";
export default defineConfig({
plugins: [
// Put the Codecov vite plugin after all other plugins
codecovVitePlugin({
enableBundleAnalysis: true,
bundleName: "example-vite-bundle",
oidc: {
useGitHubOIDC: true,
},
}),
],
});