OK, I think I see what you mean now.
It seems to work with “../images
”, “./images
” and “images
” as if they are all the same.
Yes, that is odd behavior. I also notice that this:
export const Background = styled.div`
display: flex;
flex-direction: column;
background: url(${({ src }) =>
src ? `../../../../images/misc/${src}.jpg` : "../../../../images/misc/home-bg.jpg"})
top left / cover no-repeat;
`;
works just fine.
I’m guessing what is happening is that you cannot go above the public folder - that is kind of the point of it. So, I would guess that it just ignores anything that takes you below the public folder - because you’re not allowed to go there.
It’s not ignoring the “..
” because this:
export const Background = styled.div`
display: flex;
flex-direction: column;
background: url(${({ src }) =>
"images/../misc/home-bg.jpg"})
top left / cover no-repeat;
`;
that would evaluate to /misc/home-bg.jpg
.
But this does:
export const Background = styled.div`
display: flex;
flex-direction: column;
background: url(${({ src }) =>
"images/../images/misc/home-bg.jpg"})
top left / cover no-repeat;
`;
We go into images
, back up one (to the root public folder) but then do images/misc/home-bg.jpg
.
So I guess it will allow you to back up a level (..
) as long as you don’t go below the root public folder - it just seems to ignore anything that does that.
Just to confirm that, this works:
export const Background = styled.div`
display: flex;
flex-direction: column;
background: url(${({ src }) =>
"images/../../../images/misc/home-bg.jpg"})
top left / cover no-repeat;
`;
I don’t know where that behavior is documented, but that seems to be what it is doing. And it does kind of make sense.