mirror of
https://github.com/lobehub/lobehub.git
synced 2026-03-27 13:29:15 +07:00
🔨 chore: Add Codecov Bundle Analysis (#6698)
* Add Codecov Bundle Analysis integration - Add @codecov/webpack-plugin for bundle size tracking - Configure bundle analysis settings in codecov.yml - Update CI workflow to include bundle analysis step - Set bundle change threshold to 10KB * Use nextjs-webpack-plugin * Seperate workflow Move the Build with Bundle Analysis step to its own GitHub Actions workflow file. * Revert line additon change --------- Co-authored-by: katia-sentry <katia.al-amir@sentry.com>
This commit is contained in:
22
.github/workflows/bundle-analysis.yml
vendored
Normal file
22
.github/workflows/bundle-analysis.yml
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
name: Bundle Analysis
|
||||
|
||||
on: [push, pull_request]
|
||||
|
||||
jobs:
|
||||
analyze:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Install bun
|
||||
uses: oven-sh/setup-bun@v1
|
||||
with:
|
||||
bun-version: ${{ secrets.BUN_VERSION }}
|
||||
|
||||
- name: Install deps
|
||||
run: bun i
|
||||
|
||||
- name: Build with Bundle Analysis
|
||||
run: bun run build:analyze
|
||||
env:
|
||||
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
|
||||
@@ -9,3 +9,11 @@ coverage:
|
||||
flags:
|
||||
- app
|
||||
patch: off
|
||||
|
||||
comment:
|
||||
layout: "bundle"
|
||||
require_changes: true
|
||||
require_base: true
|
||||
require_head: true
|
||||
require_bundle_changes: true
|
||||
bundle_change_threshold: "10Kb"
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import analyzer from '@next/bundle-analyzer';
|
||||
import { withSentryConfig } from '@sentry/nextjs';
|
||||
import { codecovNextJSWebpackPlugin } from '@codecov/nextjs-webpack-plugin';
|
||||
import withSerwistInit from '@serwist/next';
|
||||
import type { NextConfig } from 'next';
|
||||
import ReactComponentName from 'react-scan/react-component-name/webpack';
|
||||
@@ -256,6 +257,18 @@ const nextConfig: NextConfig = {
|
||||
layers: true,
|
||||
};
|
||||
|
||||
// Add Codecov webpack plugin
|
||||
if (process.env.CODECOV_TOKEN) {
|
||||
config.plugins.push(
|
||||
codecovNextJSWebpackPlugin({
|
||||
enableBundleAnalysis: true,
|
||||
bundleName: 'lobechat-bundle',
|
||||
uploadToken: process.env.CODECOV_TOKEN,
|
||||
webpack: config,
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
// 开启该插件会导致 pglite 的 fs bundler 被改表
|
||||
if (enableReactScan && !isUsePglite) {
|
||||
config.plugins.push(ReactComponentName({}));
|
||||
|
||||
@@ -278,6 +278,7 @@
|
||||
"zustand-utils": "^2.1.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@codecov/nextjs-webpack-plugin": "^1.9.0",
|
||||
"@commitlint/cli": "^19.8.1",
|
||||
"@edge-runtime/vm": "^5.0.0",
|
||||
"@huggingface/tasks": "^0.15.9",
|
||||
|
||||
Reference in New Issue
Block a user