Skip to content

Commit

Permalink
fix: web build 깨지는 이슈 수정 (#205)
Browse files Browse the repository at this point in the history
  • Loading branch information
saseungmin authored Oct 19, 2024
1 parent 64f9115 commit 5a50e81
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 46 deletions.
21 changes: 11 additions & 10 deletions apps/web/next.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
const { codecovNextJSWebpackPlugin } = require('@codecov/nextjs-webpack-plugin');
const path = require('path');

const isProd = process.env.NODE_ENV === 'production';
Expand Down Expand Up @@ -41,7 +40,7 @@ const nextConfig = {
experimental: {
typedRoutes: true,
},
webpack(config, options) {
webpack(config) {
const fileLoaderRule = config.module.rules.find((rule) => rule.test?.test?.('.svg'));

// eslint-disable-next-line no-param-reassign
Expand All @@ -63,14 +62,16 @@ const nextConfig = {

fileLoaderRule.exclude = /\.svg$/i;

config.plugins.push(
codecovNextJSWebpackPlugin({
enableBundleAnalysis: true,
bundleName: '@dnd-academy/web',
uploadToken: process.env.CODECOV_TOKEN,
webpack: options.webpack,
}),
);
// if (!options.dev) {
// config.plugins.push(
// codecovNextJSWebpackPlugin({
// enableBundleAnalysis: true,
// bundleName: '@dnd-academy/web',
// uploadToken: process.env.CODECOV_TOKEN,
// webpack: options.webpack,
// }),
// );
// }

return config;
},
Expand Down
26 changes: 10 additions & 16 deletions apps/web/src/app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import { notFound } from 'next/navigation';

import {
api, type CurrentApplicantCount, type FAQ, serverErrorHandling,
api, type CurrentApplicantCount, type FAQ,
} from '@dnd-academy/core';

import HomePage from '@/components/pages/HomePage';
Expand All @@ -18,19 +16,15 @@ type Props = {
};

async function Home({ searchParams }: Props) {
const currentApplicantCountData = await serverErrorHandling(() => api<CurrentApplicantCount>({
url: '/blob/latest/current_applicant_count',
type: 'bff',
}));

const faqData = await serverErrorHandling(() => api<FAQ[]>({
url: '/blob/latest/faq',
type: 'bff',
}));

if (!currentApplicantCountData || !faqData) {
notFound();
}
const currentApplicantCountData = await api<CurrentApplicantCount>({
url: '/current_applicant_count.json',
type: 'blob',
});

const faqData = await api<FAQ[]>({
url: '/faq.json',
type: 'blob',
});

const currentApplicantCount = checkNumber(currentApplicantCountData?.designer)
+ checkNumber(currentApplicantCountData?.developer);
Expand Down
18 changes: 5 additions & 13 deletions apps/web/src/components/organisms/CounterCardSection/index.tsx
Original file line number Diff line number Diff line change
@@ -1,24 +1,19 @@
import { type TotalCountStatus } from '@dnd-academy/core';
import { CounterCard } from '@dnd-academy/ui';
import { withServerErrorBoundary } from '@dnd-academy/ui/server';

import SectionTitle from '@/components/atoms/SectionTitle';
import { totalCountStatusData } from '@/lib/assets/data';
import { CURRENT_FLAG } from '@/lib/constants';

import styles from './index.module.scss';

type Props = {
title: string;
data: TotalCountStatus;
};

async function CounterCardSection({ title, data }: Props) {
async function CounterCardSection({ title }: Props) {
const {
cumulativeApplicants,
totalParticipants,
totalProjects,
dropouts,
} = data;
cumulativeApplicants, dropouts, totalParticipants, totalProjects,
} = totalCountStatusData;

return (
<SectionTitle title={title}>
Expand All @@ -32,7 +27,4 @@ async function CounterCardSection({ title, data }: Props) {
);
}

export default withServerErrorBoundary(CounterCardSection, {
url: '/blob/latest/total_count_status',
type: 'bff',
});
export default CounterCardSection;
2 changes: 2 additions & 0 deletions apps/web/src/lib/assets/data/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ import jobsData from './jobs.json';
import organizersData from './organizers.json';
import projectsData from './projects.json';
import reviewsData from './reviews.json';
import totalCountStatusData from './total_count_status.json';

export {
eventStatusData,
jobsData,
organizersData,
projectsData,
reviewsData,
totalCountStatusData,
};
6 changes: 6 additions & 0 deletions apps/web/src/lib/assets/data/total_count_status.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"cumulativeApplicants": 5032,
"dropouts": 2,
"totalParticipants": 532,
"totalProjects": 84
}
13 changes: 6 additions & 7 deletions packages/core/src/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,11 @@ import { paramsSerializer } from '../utils';
type Method =
| 'get' | 'GET'
| 'delete' | 'DELETE'
| 'head' | 'HEAD'
| 'options' | 'OPTIONS'
| 'post' | 'POST'
| 'put' | 'PUT'
| 'patch' | 'PATCH'
| 'purge' | 'PURGE'
| 'link' | 'LINK'
| 'unlink' | 'UNLINK';
| 'patch' | 'PATCH';

export type UrlPrefixType = 'public' | 'bff';
export type UrlPrefixType = 'public' | 'bff' | 'blob';

export interface ApiRequest<T = unknown> {
url: string;
Expand All @@ -35,6 +30,10 @@ const getUrl = (url: string, type: UrlPrefixType) => {
return `${process.env.NEXT_PUBLIC_ORIGIN}/api${url}`;
}

if (type === 'blob') {
return `${process.env.NEXT_PUBLIC_VERCEL_BLOB_HOST}${url}`;
}

return url;
};

Expand Down

0 comments on commit 5a50e81

Please sign in to comment.