I am currently utilizing Next.js version 14 to construct a webpage with the setup showcased in the image provided below.
https://i.sstatic.net/IMxlm.png
Within my index.module.scss
file, I have integrated an image for the background design.
The snippet of code is visible below:
&::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 the url
attribute is located within the /public/img
directory, thus the path in the url
begins at /img
.
I aim to modify the path of the url
in the index.module.scss
file during both npm run dev
and npm run build
operations.
During development (dev
), which runs locally on localhost:3000
, no changes are necessary. However, during production deployment (build
), I wish for it to be situated at the second level domain sampledomain.com/path-to-site/
.
Please refrain from providing solutions involving web search, blog posts, or responses generated by Chat GPT.
For instance, previous suggestions involved incorporating environment variables before the path, but this resulted in errors.
In addition, I lack knowledge on how to configure webpack
within next.config.js
, as my expertise does not extend to webpack configurations.