Skip to content

Build your personal knowledge base with Trilium Notes

ci(standalone): add Codecov bundle analysis for standalone build

Elian Dorandf3cd09812a0
diff --git a/.github/workflows/deploy-app.yml b/.github/workflows/deploy-app.yml
index dad7966870..ae3e87a1eb 100644
--- a/.github/workflows/deploy-app.yml
+++ b/.github/workflows/deploy-app.yml
@@ -56,6 +56,8 @@ jobs:
- name: Trigger build of app
run: pnpm --filter=standalone build
+ env:
+ CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
- name: Deploy
uses: ./.github/actions/deploy-to-cloudflare-pages
diff --git a/apps/standalone/package.json b/apps/standalone/package.json
index bbb8cae030..dcdeb606d5 100644
--- a/apps/standalone/package.json
+++ b/apps/standalone/package.json
@@ -76,6 +76,7 @@
"devDependencies": {
"@types/aes-js": "3.1.4",
"@ckeditor/ckeditor5-inspector": "5.0.0",
+ "@codecov/vite-plugin": "2.0.1",
"@preact/preset-vite": "2.10.5",
"@types/bootstrap": "5.2.10",
"@types/jquery": "4.0.0",
diff --git a/apps/standalone/vite.config.mts b/apps/standalone/vite.config.mts
index d2347d41a4..ba82d5049a 100644
--- a/apps/standalone/vite.config.mts
+++ b/apps/standalone/vite.config.mts
@@ -1,6 +1,7 @@
import fs from "fs";
import { join, resolve, sep } from "path";
+import { codecovVitePlugin } from "@codecov/vite-plugin";
import prefresh from "@prefresh/vite";
import { defineConfig, type Plugin } from "vite";
import { viteStaticCopy } from "vite-plugin-static-copy";
@@ -197,6 +198,20 @@ if (process.env.TRILIUM_INTEGRATION_TEST) {
]
}
+if (!isDev) {
+ // Put the Codecov vite plugin after all other plugins.
+ // Gated on CODECOV_TOKEN so it stays a no-op locally and in the
+ // integration-test build (which sets no token).
+ plugins = [
+ ...plugins,
+ codecovVitePlugin({
+ enableBundleAnalysis: process.env.CODECOV_TOKEN !== undefined,
+ bundleName: "standalone",
+ uploadToken: process.env.CODECOV_TOKEN
+ })
+ ];
+}
+
export default defineConfig(() => ({
root: join(__dirname, 'src'), // Set src as root so index.html is served from /
envDir: __dirname, // Load .env files from standalone directory, not src/
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 15d27bad15..353d3c5e94 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -1019,6 +1019,9 @@ importers:
'@ckeditor/ckeditor5-inspector':
specifier: 5.0.0
version: 5.0.0
+ '@codecov/vite-plugin':
+ specifier: 2.0.1
'@preact/preset-vite':
specifier: 2.10.5