Skip to content

Commit 77a27af

Browse files
committed
chore: next.js project에도 bundle analyze와 부하 테스트트 스크립트 추가 (#ci-advancement)
1 parent fd424f5 commit 77a27af

File tree

4 files changed

+164
-2
lines changed

4 files changed

+164
-2
lines changed

pnpm-lock.yaml

Lines changed: 119 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

services/one-app/next.config.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
const withBundleAnalyzer = require('@next/bundle-analyzer')({
2+
enabled: process.env.ANALYZE === 'true',
3+
});
4+
15
/** @type {import('next').NextConfig} */
26
const nextConfig = {
37
experimental: {
@@ -37,4 +41,4 @@ const nextConfig = {
3741
},
3842
};
3943

40-
export default nextConfig;
44+
module.exports = withBundleAnalyzer(nextConfig);

services/one-app/package.json

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,11 @@
1515
"lint:fix": "pnpm lint:es:fix && pnpm lint:etc:fix",
1616
"test": "jest",
1717
"test:watch": "jest --watch",
18-
"test:coverage": "jest --coverage"
18+
"test:coverage": "jest --coverage",
19+
"analyze": "ANALYZE=true next build",
20+
"test:perf": "node scripts/performance-test.mjs",
21+
"test:perf:load": "autocannon http://localhost:3000",
22+
"test:perf:lighthouse": "lighthouse http://localhost:3000 --view"
1923
},
2024
"dependencies": {
2125
"@lexical/react": "^0.21.0",
@@ -47,6 +51,7 @@
4751
"devDependencies": {
4852
"@ahhachul/utils": "workspace:*",
4953
"@faker-js/faker": "^9.0.3",
54+
"@next/bundle-analyzer": "^15.1.6",
5055
"@svgr/webpack": "^8.1.0",
5156
"@tanstack/react-query-devtools": "^5.59.16",
5257
"@testing-library/dom": "^10.4.0",
@@ -59,11 +64,14 @@
5964
"@types/react": "^19",
6065
"@types/react-dom": "^19",
6166
"@types/react-lazy-load-image-component": "^1.6.4",
67+
"autocannon": "^8.0.0",
6268
"autoprefixer": "^10.0.1",
6369
"clsx": "^2.1.1",
6470
"jest": "^29.7.0",
6571
"jest-environment-jsdom": "^29.7.0",
72+
"lighthouse": "^12.3.0",
6673
"msw": "^2.5.2",
74+
"puppeteer": "^24.1.1",
6775
"postcss": "^8",
6876
"tailwind-merge": "^2.5.4",
6977
"tailwindcss": "^3.3.0",
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import autocannon from 'autocannon';
2+
import lighthouse from 'lighthouse';
3+
import puppeteer from 'puppeteer';
4+
5+
async function runPerformanceTests() {
6+
// Lighthouse 테스트
7+
const browser = await puppeteer.launch({ headless: true });
8+
const results = await lighthouse('http://localhost:3000', {
9+
port: new URL(browser.wsEndpoint()).port,
10+
output: 'html',
11+
logLevel: 'info',
12+
});
13+
14+
console.log('Lighthouse scores:', results.lhr.categories.performance.score * 100);
15+
16+
// 부하 테스트
17+
const loadTestResults = await autocannon({
18+
url: 'http://localhost:3000',
19+
connections: 10,
20+
duration: 10,
21+
});
22+
23+
console.log('Load test results:', {
24+
'Avg Latency': loadTestResults.latency.average,
25+
'Req/Sec': loadTestResults.requests.average,
26+
});
27+
28+
await browser.close();
29+
}
30+
31+
runPerformanceTests().catch(console.error);

0 commit comments

Comments
 (0)