Skip to content

Commit

Permalink
Simplify config
Browse files Browse the repository at this point in the history
  • Loading branch information
jackyef committed Mar 3, 2024
1 parent 4f443ef commit 9087c4f
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 294 deletions.
10 changes: 9 additions & 1 deletion .github/workflows/relative-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,15 @@ jobs:
- name: Install dependencies
run: pnpm install

- name: Build and send stats.json to RelativeCI
- name: Build project
run: pnpm build
env:
RELATIVE_CI_KEY: ${{ secrets.RELATIVE_CI_KEY }}

# Send bundle stats and build information to RelativeCI
- name: Send bundle stats to RelativeCI
uses: relative-ci/agent-action@v2
with:
webpackStatsFile: ./webpack-stats.json
key: ${{ secrets.RELATIVE_CI_KEY }}
token: ${{ secrets.GITHUB_TOKEN }}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,6 @@ yarn-error.log*

# vercel
.vercel

# relative-ci
webpack-stats.json
20 changes: 10 additions & 10 deletions next.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const { StatsWriterPlugin } = require('webpack-stats-plugin');
const { RelativeCiAgentWebpackPlugin } = require('@relative-ci/agent');
const filterWebpackStats =
require('@bundle-stats/plugin-webpack-filter').default;
const withBundleAnalyzer = require('@next/bundle-analyzer')({
enabled: process.env.ANALYZE === 'true',
});
Expand All @@ -14,25 +15,24 @@ const conf = {
images: {
formats: ['image/avif', 'image/webp'],
},
webpack: function (config, options) {
webpack: (config, options) => {
const { dev, isServer } = options;

// Output webpack stats JSON file only for
// client-side/production build
if (!dev && !isServer) {
config.plugins.push(
new RelativeCiAgentWebpackPlugin({
stats: { excludeAssets: [/stats.json/] },
}),
);
config.plugins.push(
new StatsWriterPlugin({
filename: 'stats.json',
filename: '../webpack-stats.json',
stats: {
context: './', // optional, will improve readability of the paths
assets: true,
entrypoints: true,
chunks: true,
modules: true,
},
transform: (webpackStats) => {
const filteredSource = filterWebpackStats(webpackStats);
return JSON.stringify(filteredSource);
},
}),
);
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
},
"devDependencies": {
"@builder.io/partytown": "^0.6.2",
"@bundle-stats/plugin-webpack-filter": "^4.12.0",
"@jsdevtools/rehype-toc": "^3.0.2",
"@mapbox/rehype-prism": "^0.5.0",
"@next/eslint-plugin-next": "^12.0.1",
"@relative-ci/agent": "^4.2.5",
"@tailwindcss/aspect-ratio": "^0.4.0",
"@tailwindcss/forms": "^0.5.0",
"@tailwindcss/line-clamp": "^0.3.1",
Expand Down
Loading

0 comments on commit 9087c4f

Please sign in to comment.