#Image

55 messages · Page 1 of 1 (latest)

sterile gull
#

i added the corect path of an image but it is not apeaing oonn the site idk why

kind star
# sterile gull

the @ alias only works if you defined it in your config (IE vite.config.js or webpack.config.js)

#

resolve: {
alias: {
'@': path.resolve(__dirname, 'src'),
},
}

kind star
#

replace @ with .

#

but it depends on where your code file is

#

tell me if it works

sterile gull
#

it does apeaar when i rrun the build but in dev env its not apearing

kind star
#

That means that the @ alias is not recognised probably

#

Do you have a config.js file?

#

did you try changing the @ to a .

sterile gull
kind star
#

ah

#

can you give me the path of the code file that contains the line of your import?

#

just a screenshot is fine

#

is it in src?

sterile gull
#

yeah

#

the import code and the images ae in src

kind star
#

try moving the logo.svg into src, and replace your code with
import logoImage from "./logo.svg";

This only works if both the logo.svg and the code file containing this import are in the same folder (IE src)

sterile gull
#

the logo.svg is in src/asserts/images

kind star
#

can you send me a screenshot of your entire files please, so i can see src folder and i can see the logo.svg location

sterile gull
kind star
#

yes but you can send it in vscode? So i can see everything. Also I want to see the src folder pls

sterile gull
#

AL

kind star
#

like this you know

sterile gull
#

alr wait

kind star
#

so i can see logo.svg, and the file you are using to import it

sterile gull
kind star
#

oh bro it's normal

#

your nvbar is not inside src, which is not a bad thing

#

but that means that you have to change the code to
import logoImage from '../assets/images/logo.svg';

#

should work now

sterile gull
#

i did tht still no logo cryingmichaeljordan

kind star
#

huh

sterile gull
kind star
#

if it is not red under the code, that means that the path is correct

#

so this is fixed

#

but maybe there is another issue

#

you did save the file before running the npm dev?

sterile gull
#

yeah

kind star
#

well since the issue is not in the import, maybe it is in the code of Navbar.tsx. Can you send me your code maybe with gist?

https://gist.github.com/

You can put the entire Navbar.tsx in there

Gist

GitHub Gist: instantly share code, notes, and snippets.

#

then just press the green button and give me the link, i will check it out

sterile gull
kind star
#

I see, you are using nextjs

remove this line
import logoImage from "../assets/images/logo.svg";

and now find this
<Image
src={logoImage}
alt="Site Logo"
className="h-9 md:h-auto w-auto"
/>

And replace this whole block of code with:
<img
src="/assets/images/logo.svg"
alt="Site Logo"
className="h-9 md:h-auto w-auto"
/>

And it should work. Tell me if it does

sterile gull
#

nnah doset work 95_CryThumbsUp

kind star
# sterile gull

so, your logo image is in
src/assets/images/logo.svg

so for it to work, you need to move it inside
public/assets/images/logo.svg

see that public folder in vscode? Well, you do whatever you want but I think it is best practice to put assets there because they can be referenced by default in code.

If you keep yout images inside src/assets/images it will be harder because you will need to import them as a react component using @svgr so extra config

#

basically, put your logo inside public/assets/images/logo.svg and it should work.

sterile gull
#

alr tysm

#

i'll fix that