3

After running next build and next export, I don't see images assigned in background-image in css. I discovered that the reason for this is a wrong path after doing the next export. Image path after page export to static files: file:///C:/Users/user/Documents/frontend/out/_next/static/css**/_next/static/media/logoR.8b482e024d38c471760fb327b4c4da3e.png**

(The bold font is the path that still doesn't exist in the file folder.) But the real path is: C:\Users\user\Documents\frontend\out\image\logoR.png

What do I need to do to make the path to the background-images fit correctly when doing the next export?

2 Answers 2

0

Have you added your image loader in your next.config.js file?

If not add this code in your next.config.js file:

module.exports = {
    images: {
        loader: "imgix",
        path: "",
    },
};

Make sure your images are inside the PUBLIC folder.

Sign up to request clarification or add additional context in comments.

Comments

0

I had the exact same issue. I tried a lot of things none of them worked.

The path worked when I ran it locally with npm run dev. Then I exported it and opened the html file locally and it didn't work; the background was not loaded.

Turns out it had to be deployed. After I deployed the exported static site to CloudFlare it worked.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.