Skip to content

Commit

Permalink
chore: Setup RelativeCI for bundle comparison (#254)
Browse files Browse the repository at this point in the history
  • Loading branch information
evadecker authored Dec 5, 2024
1 parent 1467c8e commit 255485b
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 1 deletion.
50 changes: 50 additions & 0 deletions .github/workflows/relative-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Bundle Size

on:
push:
branches: main
pull_request:
branches: main

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

permissions:
contents: read
pull-requests: write

jobs:
build:
name: Build and report bundle stats
runs-on: ubuntu-latest

steps:
- name: Checkout repo
uses: actions/checkout@v4

- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
run_install: false

- name: Setup Node.js 20
uses: actions/setup-node@v4
with:
node-version: 20
cache: 'pnpm'

- name: Install dependencies
run: pnpm install

# Build and output bundle stats to webpack-stats.json
- name: Build
run: pnpm build -- --json webpack-stats.json

# Send bundle stats and build information to RelativeCI
- name: Send bundle stats to RelativeCI
uses: relative-ci/agent-action@v2
with:
webpackStatsFile: ./dist/webpack-stats.json
key: ${{ secrets.RELATIVE_CI_KEY }}
token: ${{ secrets.GITHUB_TOKEN }}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@
"lint-staged": "^15.2.10",
"npm-run-all": "^4.1.5",
"prop-types": "^15.8.1",
"rollup-plugin-webpack-stats": "^1.1.1",
"tailwind-merge": "^2.5.5",
"tailwindcss-aria-attributes": "^2.0.1",
"tailwindcss-radix-colors": "^1.4.1",
Expand Down
13 changes: 13 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 18 additions & 1 deletion vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,30 @@ import { TanStackRouterVite } from "@tanstack/router-plugin/vite";
import react from "@vitejs/plugin-react-swc";
import autoprefixer from "autoprefixer";
import cssnano from "cssnano";
import webpackStatsPlugin from "rollup-plugin-webpack-stats";
import tailwindcss from "tailwindcss";
import { defineConfig } from "vite";
import tsconfigPaths from "vite-tsconfig-paths";

// https://vitejs.dev/config/
export default defineConfig({
plugins: [TanStackRouterVite(), tsconfigPaths(), react()],
build: {
rollupOptions: {
output: {
// Use a supported file pattern for Vite 5/Rollup 4
// @doc https://relative-ci.com/documentation/guides/vite-config
assetFileNames: "assets/[name].[hash][extname]",
chunkFileNames: "assets/[name].[hash].js",
entryFileNames: "assets/[name].[hash].js",
},
},
},
plugins: [
TanStackRouterVite(),
tsconfigPaths(),
react(),
webpackStatsPlugin(),
],
define: {
APP_VERSION: JSON.stringify(process.env.npm_package_version),
},
Expand Down

0 comments on commit 255485b

Please sign in to comment.