I am using Next.js v14 to create a page with the configuration in the attached image.
In index.module.scss, I am using an image for the background.
Below is a portion of the code.
&::before {
left: 0;
background: url(/img/pc/index_hero_bg1.png) 0 0 repeat-x;
}
&::after {
right: 0;
background: url(/img/pc/index_hero_bg2.png) 0 0 repeat-x;
}
The image specified in url is in /public/img, so the image path in url starts at /img.
I want to change the path of url in index.module.scss in npm run dev and npm run build.
The dev is localhost:3000, so I can leave it as it is, but for the build I want it to be on the second level sampledomain.com/path-to-site/.
No search, no blog post, and no answer using Chat GPT.
For example, the answer was to put the environment variable in front of the path, but I get an error.
Also, I don't know how to configure webpack in next.config.js, because I have no knowledge of webpack.

you need to define the asset prefix in your next.config.js file.
in your SCSS file, you can reference the background images
edit: