From c7e3624605a84713ad96bf8bf3f36f9c1de48fae Mon Sep 17 00:00:00 2001 From: Joe Karow <58997957+JoeKarow@users.noreply.github.com> Date: Wed, 24 Apr 2024 16:02:50 -0400 Subject: [PATCH] relative-ci config --- apps/app/.eslintignore | 1 + apps/app/.gitignore | 2 ++ apps/app/.prettierignore | 1 + apps/app/next.config.mjs | 22 ++++++++++++++++++++++ apps/app/package.json | 4 +++- pnpm-lock.yaml | 11 +++++++++++ 6 files changed, 40 insertions(+), 1 deletion(-) diff --git a/apps/app/.eslintignore b/apps/app/.eslintignore index 66fb2ac992..75c0aef1f1 100644 --- a/apps/app/.eslintignore +++ b/apps/app/.eslintignore @@ -1 +1,2 @@ *.spec.ts +webpack-stats.json diff --git a/apps/app/.gitignore b/apps/app/.gitignore index 86fcaae04b..e742dd8bea 100644 --- a/apps/app/.gitignore +++ b/apps/app/.gitignore @@ -44,3 +44,5 @@ yarn-error.log* # Sentry Auth Token .sentryclirc + +webpack-stats.json diff --git a/apps/app/.prettierignore b/apps/app/.prettierignore index 0959e3aaed..8ccb126b3b 100644 --- a/apps/app/.prettierignore +++ b/apps/app/.prettierignore @@ -12,3 +12,4 @@ pnpm-lock.yaml .DS_Store .eslintignore .trace/*.json +webpack-stats.json diff --git a/apps/app/next.config.mjs b/apps/app/next.config.mjs index f5c62cb29a..ca20030ae0 100644 --- a/apps/app/next.config.mjs +++ b/apps/app/next.config.mjs @@ -1,11 +1,13 @@ /* eslint-disable node/no-process-env */ +import filterWebpackStats from '@bundle-stats/plugin-webpack-filter' import bundleAnalyze from '@next/bundle-analyzer' import { PrismaPlugin } from '@prisma/nextjs-monorepo-workaround-plugin' import { RelativeCiAgentWebpackPlugin } from '@relative-ci/agent' import { withSentryConfig } from '@sentry/nextjs' import { I18NextHMRPlugin } from 'i18next-hmr/webpack' import routes from 'nextjs-routes/config' +import { StatsWriterPlugin } from 'webpack-stats-plugin' import path from 'path' import { fileURLToPath } from 'url' @@ -68,6 +70,26 @@ const nextConfig = { } if (!dev && !isServer) { config.plugins.push(new RelativeCiAgentWebpackPlugin()) + config.plugins.push( + new StatsWriterPlugin({ + filename: '../webpack-stats.json', + stats: { + assets: true, + chunks: true, + modules: true, + }, + transform: (webpackStats) => { + if (filterWebpackStats instanceof Function) { + const filteredSource = filterWebpackStats(webpackStats) + return JSON.stringify(filteredSource) + } else if (filterWebpackStats.default instanceof Function) { + const filteredSource = filterWebpackStats.default(webpackStats) + return JSON.stringify(filteredSource) + } + return JSON.stringify(webpackStats) + }, + }) + ) } if (dev && !isServer) { /** WDYR */ diff --git a/apps/app/package.json b/apps/app/package.json index dd2e204904..8ca42c6e9a 100644 --- a/apps/app/package.json +++ b/apps/app/package.json @@ -106,6 +106,7 @@ "zod": "3.23.3" }, "devDependencies": { + "@bundle-stats/plugin-webpack-filter": "4.12.2", "@hookform/devtools": "4.3.1", "@playwright/test": "1.43.1", "@prisma/nextjs-monorepo-workaround-plugin": "5.13.0", @@ -136,7 +137,8 @@ "trpc-playground": "1.0.4", "type-fest": "4.16.0", "typescript": "5.4.5", - "webpack-bundle-analyzer": "4.10.2" + "webpack-bundle-analyzer": "4.10.2", + "webpack-stats-plugin": "1.1.3" }, "ct3aMetadata": { "initVersion": "5.10.1" diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index c1e1fa9fe1..98b394516a 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -343,6 +343,9 @@ importers: specifier: 3.23.3 version: 3.23.3 devDependencies: + '@bundle-stats/plugin-webpack-filter': + specifier: 4.12.2 + version: 4.12.2(core-js@3.36.1) '@hookform/devtools': specifier: 4.3.1 version: 4.3.1(@types/react@18.2.79)(react-dom@18.2.0(react@18.2.0))(react@18.2.0) @@ -436,6 +439,9 @@ importers: webpack-bundle-analyzer: specifier: 4.10.2 version: 4.10.2(bufferutil@4.0.8)(utf-8-validate@6.0.3) + webpack-stats-plugin: + specifier: 1.1.3 + version: 1.1.3 apps/web: dependencies: @@ -14348,6 +14354,9 @@ packages: resolution: {integrity: sha512-/DyMEOrDgLKKIG0fmvtz+4dUX/3Ghozwgm6iPp8KRhvn+eQf9+Q7GWxVNMk3+uCPWfdXYC4ExGBckIXdFEfH1w==} engines: {node: '>=10.13.0'} + webpack-stats-plugin@1.1.3: + resolution: {integrity: sha512-yUKYyy+e0iF/w31QdfioRKY+h3jDBRpthexBOWGKda99iu2l/wxYsI/XqdlP5IU58/0KB9CsJZgWNAl+/MPkRw==} + webpack-virtual-modules@0.5.0: resolution: {integrity: sha512-kyDivFZ7ZM0BVOUteVbDFhlRt7Ah/CSPwJdi8hBpkK7QLumUqdLtVfm/PX/hkcnrvr0i77fO5+TjZ94Pe+C9iw==} @@ -31140,6 +31149,8 @@ snapshots: webpack-sources@3.2.3: {} + webpack-stats-plugin@1.1.3: {} + webpack-virtual-modules@0.5.0: {} webpack-virtual-modules@0.6.1: {}