diff --git a/.github/workflows/relative-ci.yml b/.github/workflows/relative-ci.yml new file mode 100644 index 0000000..02803e8 --- /dev/null +++ b/.github/workflows/relative-ci.yml @@ -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 }} diff --git a/package.json b/package.json index b7478f9..474d126 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index e1ff4f3..2275a7e 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -250,6 +250,9 @@ importers: prop-types: specifier: ^15.8.1 version: 15.8.1 + rollup-plugin-webpack-stats: + specifier: ^1.1.1 + version: 1.1.1(rollup@4.27.3) tailwind-merge: specifier: ^2.5.5 version: 2.5.5 @@ -5343,6 +5346,12 @@ packages: deprecated: Rimraf versions prior to v4 are no longer supported hasBin: true + rollup-plugin-webpack-stats@1.1.1: + resolution: {integrity: sha512-omUl6WNXvini+SjG8gCHNNXeee5mJ9yXK9+cUi7xmFlHteAg5KQN2Os3T7aw62ET/1f50WJRjrLPe+9TOCbWNA==} + engines: {node: '>=18'} + peerDependencies: + rollup: ^3.0.0 || ^4.0.0 + rollup@4.27.3: resolution: {integrity: sha512-SLsCOnlmGt9VoZ9Ek8yBK8tAdmPHeppkw+Xa7yDlCEhDTvwYei03JlWo1fdc7YTfLZ4tD8riJCUyAgTbszk1fQ==} engines: {node: '>=18.0.0', npm: '>=8.0.0'} @@ -12023,6 +12032,10 @@ snapshots: glob: 7.2.3 optional: true + rollup-plugin-webpack-stats@1.1.1(rollup@4.27.3): + dependencies: + rollup: 4.27.3 + rollup@4.27.3: dependencies: '@types/estree': 1.0.6 diff --git a/vite.config.ts b/vite.config.ts index 7de2b05..7988a04 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -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), },