next build하기

개발공부·2023년 2월 3일
0

* 결과

1) client

2) nodejs

* next build하기

package.json에 해당 내용 들어있어야 함

"scripts": {
    "dev": "next -p 3000",
    "build": "next build",
    "start": "next start"
  },

npm run build

  • next build한 것 분석하기

npm i @next/bundle-analyzer

* next.config.js

const withBundleAnalyzer = require("@next/bundle-analyzer")({
  enabled: process.env.ANALYZE === "true",
});

module.exports = withBundleAnalyzer({
  compress: true,
  webpack(config, { webpack }) {
    const prod = process.env.NODE_ENV === "production";
    return {
      ...config,
      mode: prod ? "production" : "development",
      devtool: prod ? "hidden-source-map" : "eval-source-map",
      plugins: [
        ...config.plugins,
        new webpack.ContextReplacementPlugin(/moment[/\\]locale$/, /^\.\/ko$/),
      ],
    };
  },
});

* cross-env 설치

npm i cross-env

package.json에 내용 수정

 "scripts": {
    "dev": "next -p 3000",
    "build": "cross-env ANALYZE=true NODE_ENV=production next build",
    "start": "next start"
  },
profile
개발 블로그, 티스토리(https://ba-gotocode131.tistory.com/)로 갈아탐

0개의 댓글