next export したプロジェクトを firebase deploy した際に画像など静的ファイルが表示されず困っています。
firebase.jsonは下記の様になっています。
json
1{ 2 "hosting": { 3 "public": "out", 4 "ignore": [ 5 "firebase.json", 6 "**/.*", 7 "**/node_modules/**" 8 ], 9 "rewrites": [ 10 { 11 "source": "**", 12 "destination": "/index.html" 13 } 14 ] 15 } 16} 17
export した際に作られる out ディレクトリには画像ファイルも入っています。
実行しているコマンドは以下になります。
next build && next export
firebase deploy --project hoge
こちらでexportした後に next start でローカルで確認すると問題なく表示されています。
コード上は下記の様にパスを指定して画像を表示しています。
jsx
1import React from 'react'; 2 3export const FirstSection = (): JSX.Element => ( 4 <div> 5 <div className="back"> 6 <img src="/hoge-img.png" className="text-img" /> 7 </div> 8 9 10 <style jsx>{` 11 .back { 12 background: url("/top-img.jpeg"); 13 background-repeat: no-repeat; 14 background-size: cover; 15 width: 100vw; 16 height: 100vh; 17 } 18 .text-img { 19 padding: 30%; 20 width: 50%; 21 height: auto; 22 } 23 24 `}</style> 25 </div> 26) 27 28export default FirstSection
因みに out ディレクトリの構成は
out
∟_next
∟ 404.html
∟ index.html
∟ その他画像達静的ファイル
の様になっています。
どこが問題なのでしょうか。。。どなたかお分かりになる方がいればご回答いただければ幸いです。。。。!!!
あなたの回答
tips
プレビュー