Skip to content

Commit

Permalink
Merge pull request #182 from choooz/feature/feat-optimize-code
Browse files Browse the repository at this point in the history
코드 성능 최적화 (번들 최적화, 코드스플리팅, 트리쉐이킹)
  • Loading branch information
ksmfou98 authored Oct 17, 2023
2 parents 551eb0c + 5ae2c3b commit c262f2d
Show file tree
Hide file tree
Showing 10 changed files with 332 additions and 35 deletions.
140 changes: 140 additions & 0 deletions .pnp.cjs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 10 additions & 1 deletion apps/jurumarble/next.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
console.log("START");
const withBundleAnalyzer = require("@next/bundle-analyzer")({
enabled: process.env.ANALYZE === "true",
});

/** @type {import('next').NextConfig} */
const nextConfig = {
swcMinify: true,
Expand Down Expand Up @@ -27,4 +31,9 @@ const nextConfig = {
},
};

module.exports = nextConfig;
module.exports = (_phase) => {
const plugins = [withBundleAnalyzer];
return plugins.reduce((acc, plugin) => plugin(acc), {
...nextConfig,
});
};
2 changes: 2 additions & 0 deletions apps/jurumarble/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"scripts": {
"dev": "next dev",
"build": "next build",
"analyze": "ANALYZE=true yarn build",
"start": "next start",
"lint": "next lint",
"gen": "svgr --index-template src/assets/icons/templates/indexTemplate.cjs --config-file src/assets/icons/config/basic.config.cjs",
Expand All @@ -15,6 +16,7 @@
"@emotion/is-prop-valid": "^1.2.1",
"@monorepo/hooks": "workspace:*",
"@monorepo/ui": "workspace:*",
"@next/bundle-analyzer": "13.3.5-canary.9",
"@react-hookz/web": "^23.1.0",
"@tanstack/react-query": "^4.33.0",
"@tanstack/react-query-devtools": "^4.33.0",
Expand Down
11 changes: 6 additions & 5 deletions apps/jurumarble/src/app/drink-info/[id]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
"use client";

import BottomBar from "components/BottomBar";
import dynamic from "next/dynamic";
import React from "react";
import DrinkCommentContainer from "./components/DrinkCommentContainer";
import DrinkInfoContainer from "./components/DrinkInfoContainer";

const DynamicDrinkInfoContainer = dynamic(() => import("./components/DrinkInfoContainer"));
const DynamicDrinkCommentContainer = dynamic(() => import("./components/DrinkCommentContainer"));

function DrinkInfoPage() {
return (
<>
<DrinkInfoContainer />
<DrinkCommentContainer />
<DynamicDrinkInfoContainer />
<DynamicDrinkCommentContainer />
</>
);
}
Expand Down
6 changes: 5 additions & 1 deletion apps/jurumarble/src/app/map/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import BottomBar from "components/BottomBar";
import Header from "components/Header";
import { KAKAO_MAP_API_KEY } from "lib/constants";
import dynamic from "next/dynamic";
import Script from "next/script";
import React from "react";
import MapContainer from "./components/MapContainer";
Expand All @@ -12,6 +13,9 @@ declare global {
kakao: any;
}
}

const DynamicMapContainer = dynamic(() => import("./components/MapContainer"));

const MapPage = () => {
return (
<>
Expand All @@ -21,7 +25,7 @@ const MapPage = () => {
src={`//dapi.kakao.com/v2/maps/sdk.js?appkey=${KAKAO_MAP_API_KEY}&libraries=services&autoload=false`}
></Script>
<Header />
<MapContainer />
<DynamicMapContainer />
<BottomBar />
</>
);
Expand Down
18 changes: 10 additions & 8 deletions apps/jurumarble/src/app/my/page.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
import BottomBar from "components/BottomBar";
import Header from "components/Header";
import UserInfoContainer from "./components/UseInfoContainer";
import VoteListContainer from "./components/VoteListContainer";
import dynamic from "next/dynamic";

const DynamicHeader = dynamic(() => import("components/Header"));
const DynamicUserInfoContainer = dynamic(() => import("./components/UseInfoContainer"));
const DynamicVoteListContainer = dynamic(() => import("./components/VoteListContainer"));
const DynamicBottomBar = dynamic(() => import("components/BottomBar"));

function MyPage() {
return (
<>
<Header />
<UserInfoContainer />
<VoteListContainer />
<BottomBar />
<DynamicHeader />
<DynamicUserInfoContainer />
<DynamicVoteListContainer />
<DynamicBottomBar />
</>
);
}
Expand Down
39 changes: 29 additions & 10 deletions apps/jurumarble/src/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,44 @@
import BottomBar from "components/BottomBar";
import Header from "components/Header";
import styled, { css } from "styled-components";
import Banner from "./main/components/Banner";
import HotDrinkContainer from "./main/components/HotDrinkContainer";
import HotDrinkVoteContainer from "./main/components/HotDrinkVoteContainer";
import SearchInputWrapper from "./main/components/SearchInputWrapper";
import TodayDrinkRecommendation from "./main/components/TodayDrinkRecommendation";
import dynamic from "next/dynamic";

const DynamicHotDrinkVoteContainer = dynamic(
() => import("./main/components/HotDrinkVoteContainer"),
);

const DynamicHotDrinkContainer = dynamic(() => import("./main/components/HotDrinkContainer"), {
ssr: false,
loading: () => (
<div
style={{
height: "200px",
}}
/>
),
});

const DynamicTodayDrinkRecommendation = dynamic(
() => import("./main/components/TodayDrinkRecommendation"),
);

const DynamicSearchInputWrapper = dynamic(() => import("./main/components/SearchInputWrapper"));

const DynamicBanner = dynamic(() => import("./main/components/Banner"));

function MainPage() {
return (
<>
<Header />
<TodayDrinkRecommendation />
<DynamicTodayDrinkRecommendation />
<TopSection>
<Banner />
<SearchInputWrapper />
<HotDrinkContainer />
<DynamicBanner />
<DynamicSearchInputWrapper />
<DynamicHotDrinkContainer />
</TopSection>
<DivideLine />
<BottomSection>
<HotDrinkVoteContainer />
<DynamicHotDrinkVoteContainer />
</BottomSection>
<BottomBar />
</>
Expand Down
Loading

0 comments on commit c262f2d

Please sign in to comment.