File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -3,9 +3,12 @@ import type { NextConfig } from "next";
33const isProd = process . env . NODE_ENV === "production" ;
44const nextConfig : NextConfig = {
55 output : "export" ,
6- images : { unoptimized : true } ,
7- assetPrefix : isProd ? "/Passcodes/" : "" ,
6+ images : {
7+ loader : "custom" ,
8+ loaderFile : "src/libs/custom-image-loader.ts" ,
9+ } ,
810 basePath : isProd ? "/Passcodes" : "" ,
11+ assetPrefix : isProd ? "/Passcodes/" : "" ,
912} ;
1013
1114export default nextConfig ;
Original file line number Diff line number Diff line change 1+ // custom-image-loader.js
2+ // Code: https://stackoverflow.com/a/78220610
3+
4+ import nextConfig from "../../next.config" ;
5+ import path from "path" ;
6+
7+ const basePath = nextConfig . basePath ;
8+
9+ export default function myImageLoader ( {
10+ src,
11+ width,
12+ } : {
13+ src : string ;
14+ width : string ;
15+ } ) {
16+ if ( basePath && path . isAbsolute ( src ) ) {
17+ return `${ basePath } ${ src } ?width=${ width } ` ;
18+ }
19+ return `${ src } ?width=${ width } ` ;
20+ }
You can’t perform that action at this time.
0 commit comments