Skip to content

Commit

Permalink
Set up relative-ci (#110)
Browse files Browse the repository at this point in the history
* Set up relative-ci

* Simplify config
  • Loading branch information
jackyef authored Mar 3, 2024
1 parent 25f693e commit 1e28912
Show file tree
Hide file tree
Showing 5 changed files with 1,331 additions and 1,136 deletions.
49 changes: 49 additions & 0 deletions .github/workflows/relative-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: RelativeCI pnpm

on: push

jobs:
build:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [18.x]

steps:
- uses: actions/checkout@v3

- uses: pnpm/action-setup@v3
name: Install pnpm
with:
version: 8
run_install: false

- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- uses: actions/cache@v3
name: Setup pnpm cache
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies
run: pnpm install

- 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
27 changes: 27 additions & 0 deletions next.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
const { StatsWriterPlugin } = require('webpack-stats-plugin');
const filterWebpackStats =
require('@bundle-stats/plugin-webpack-filter').default;
const withBundleAnalyzer = require('@next/bundle-analyzer')({
enabled: process.env.ANALYZE === 'true',
});
Expand All @@ -12,6 +15,30 @@ const conf = {
images: {
formats: ['image/avif', 'image/webp'],
},
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 StatsWriterPlugin({
filename: '../webpack-stats.json',
stats: {
assets: true,
chunks: true,
modules: true,
},
transform: (webpackStats) => {
const filteredSource = filterWebpackStats(webpackStats);
return JSON.stringify(filteredSource);
},
}),
);
}

return config;
},
};

module.exports = flowRight(withBundleAnalyzer)(conf);
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
},
"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",
Expand Down Expand Up @@ -52,6 +53,7 @@
"tailwindcss": "^3.3.0",
"typescript": "^4.8.4",
"unist-util-visit": "^2.0.3",
"webpack-stats-plugin": "^1.1.3",
"xml-formatter": "^2.3.0"
},
"dependencies": {
Expand Down
Loading

0 comments on commit 1e28912

Please sign in to comment.