@@ -37,7 +37,7 @@ const ALLOWED_SVG_REGEX = new RegExp(`${sep}icons${sep}.+\\.svg$`)
3737const config = {
3838 output : undefined ,
3939 // reactStrictMode: true, provoke duplicated codemirror editors
40- webpack ( config ) {
40+ webpack ( config , { isServer , dev } ) {
4141 // #region MDX
4242 const mdxRule = config . module . rules . find ( rule => rule . test ?. test ?. ( ".mdx" ) )
4343 if ( mdxRule ) {
@@ -62,6 +62,19 @@ const config = {
6262 fileLoaderRule . exclude = / \. s v g $ / i
6363
6464 config . module . rules . push (
65+ {
66+ test : / \. ( p n g | j p g | j p e g | g i f | w e b p | a v i f | i c o | b m p | s v g | t x t ) $ / i,
67+ resourceQuery : / r e s o u r c e / ,
68+ type : "asset/resource" ,
69+ generator : {
70+ filename : "static/media/[name].[hash][ext]" ,
71+ publicPath : "/_next/" ,
72+ // Server build outputs to .next/server/, so go up to reach .next/static/
73+ outputPath : [ isServer && "../" , ! dev && "../" ]
74+ . filter ( Boolean )
75+ . join ( "" ) ,
76+ } ,
77+ } ,
6578 // All .svg from /icons/ and with ?svgr are going to be processed by @svgr/webpack
6679 {
6780 test : ALLOWED_SVG_REGEX ,
@@ -103,7 +116,7 @@ const config = {
103116 test : / \. s v g $ / i,
104117 exclude : ALLOWED_SVG_REGEX ,
105118 resourceQuery : {
106- not : [ ...fileLoaderRule . resourceQuery . not , / s v g r / ] ,
119+ not : [ ...fileLoaderRule . resourceQuery . not , / s v g r | r e s o u r c e / ] ,
107120 } ,
108121 } ,
109122 )
0 commit comments