Skip to content

Commit

Permalink
Set up relative-ci
Browse files Browse the repository at this point in the history
  • Loading branch information
jackyef committed Mar 3, 2024
1 parent 25f693e commit 4f443ef
Show file tree
Hide file tree
Showing 4 changed files with 1,597 additions and 1,138 deletions.
41 changes: 41 additions & 0 deletions .github/workflows/relative-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
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 and send stats.json to RelativeCI
run: pnpm build
env:
RELATIVE_CI_KEY: ${{ secrets.RELATIVE_CI_KEY }}
27 changes: 27 additions & 0 deletions next.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
const { StatsWriterPlugin } = require('webpack-stats-plugin');
const { RelativeCiAgentWebpackPlugin } = require('@relative-ci/agent');
const withBundleAnalyzer = require('@next/bundle-analyzer')({
enabled: process.env.ANALYZE === 'true',
});
Expand All @@ -12,6 +14,31 @@ const conf = {
images: {
formats: ['image/avif', 'image/webp'],
},
webpack: function (config, options) {
const { dev, isServer } = options;

if (!dev && !isServer) {
config.plugins.push(
new RelativeCiAgentWebpackPlugin({
stats: { excludeAssets: [/stats.json/] },
}),
);
config.plugins.push(
new StatsWriterPlugin({
filename: 'stats.json',
stats: {
context: './', // optional, will improve readability of the paths
assets: true,
entrypoints: true,
chunks: true,
modules: true,
},
}),
);
}

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 @@ -16,6 +16,7 @@
"@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 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 4f443ef

Please sign in to comment.