Atis9 / nyantech.com

https://nyantech.com
4 stars 0 forks source link

next export ができない #51

Closed Atis9 closed 1 year ago

Atis9 commented 2 years ago

バグについての説明 next export ができない

再現するために 動作を再現するための手順:

  1. yarn next build && yarn next export

期待される動作 /out に出力されること

補足説明

❯ yarn next export
yarn run v1.22.18
$ /home/atis/repositories/nyantech.com/node_modules/.bin/next export
info  - using build directory: /home/atis/repositories/nyantech.com/.next
info  - Copying "static build" directory
info  - No "exportPathMap" found in "/home/atis/repositories/nyantech.com/next.config.js". Generating map from "./pages"Error: Image Optimization using Next.js' default loader is not compatible with `next export`.
  Possible solutions:
    - Use `next start` to run a server, which includes the Image Optimization API.
    - Use any provider which supports Image Optimization (like Vercel).
    - Configure a third-party loader in `next.config.js`.
    - Use the `loader` prop for `next/image`.
  Read more: https://nextjs.org/docs/messages/export-image-api
    at /home/atis/repositories/nyantech.com/node_modules/next/dist/export/index.js:156:23
    at async Span.traceAsyncFn (/home/atis/repositories/nyantech.com/node_modules/next/dist/trace/trace.js:79:20)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Atis9 commented 2 years ago

Img (next/image) での最適化は export に対応していないことが原因。 別の方法で最適化するには下記が参考になりそう。 Image optimization for static NextJS sites

Atis9 commented 2 years ago

今回は Cloudflare Pages にデプロイを試したときに発生した事象。 素直に Vercel を使うなら対応はいらない。

Atis9 commented 2 years ago

Next.js の SSR を放り投げて SSG にのみ対応させるなら Cloudflare Pages へのデプロイを検討してもよい。 GitHub Team で GitHub Codespaces を使おうとすると Vercel Pro の契約が必須になる (Team/Organization のリポジトリは Vercel Pro でないとデプロイできない) ため、ランニングコストが高くなる。 どう運用するか含め、要検討。

Atis9 commented 2 years ago

現状 SSR でやりたいことはないので SSG に特化させていいとは思っている。 Next.js である必要もなくなってしまうと思うが。

Atis9 commented 1 year ago

Vercel で運用するので対応しない