timhagn / gatsby-background-image

Lazy-loading React (multi)background-image component with optional support for the blur-up effect.
MIT License
253 stars 49 forks source link

no background image on gatsby build #152

Closed nerdess closed 3 years ago

nerdess commented 3 years ago

Summary

Background images not showing in build :(

Relevant information

I recently switched from gatsby-image to gatsby-plugin-image. I am including my background images using gbimage-bridge, thee code is pretty straightforward:

`

{children}

`

When running gatsby develop all works fine, I get a Background Image. But when I am using gatsby build no image gets displayed.

Here is the different source code that gets generated:

Gatsby develop, all good

develop

Gatsby build, not so good, the background image is missing

build

All the other normal images that are not served through <BgImage> are fine.

Any help would be great!

nerdess commented 3 years ago

the odd thing: the images are inside the /public/static folder so the assets are there. they just don't get referenced in the CSS generated by the bgImagecomponent.

so e.g. this asset which should be displayed as background image is available in the /public/static folder:

Bildschirmfoto 2021-03-18 um 14 19 16

timhagn commented 3 years ago

Hi @nerdess,

do you talk about the initial rendering in the created .html files? Then it's probably a duplicate to #148 or at least explained there. Because with g3bitest I couldn't replicate it just now, images on /gpi (page with new syntax & gbimage-bridge) are shown as they should be oO...

Best,

Tim.

nerdess commented 3 years ago

@timhagn this is so weird, i deleted my node_modules folder and package-lock.json and did a fresh npm install. partly because i wanted to check if the repo works since i wanted to link it here for people to have a look.

but after the fresh install all works like magic....the images show up in the gatsby build as well now.

this was a total glitch in the matrix that cost me a lot of hours of just being lost and puzzled 🤷

timhagn commented 3 years ago

Hi @nerdess,

been there, had that ^^. Great you could solve it!

Best,

Tim.

MadalitsoNyemba commented 2 years ago

@nerdess , I followed what you did but still getting no image after build.