import .tsx file from public folder
Unanswered
Laysan Albatross posted this in #help-forum
Laysan AlbatrossOP
There seems to be a problem with importing a .tsx file that is located in my public folder and I don't understand why.
That's how im trying to import:
That's how im trying to import:
import { B2BRBlueten } from '/B2BR_LOGO.tsx';
import { B2BRFace } from '/B2BR_LOGO.tsx';
import { B2BRSchrift } from '/B2BR_LOGO.tsx';19 Replies
is this the actual import path? any string starting
and for the question itself, I think the bundling does work with files from the public folder but it doesn't really make sense to add source code there unless you want people to see all your code
/ will point to the root of you filesystem, which is probably completely outside your project folder, so this will never compileand for the question itself, I think the bundling does work with files from the public folder but it doesn't really make sense to add source code there unless you want people to see all your code
Laysan AlbatrossOP
It's not really source code. that are 3 <SVG> elements that I'm exporting and together they're forming the Website icon.
And as I understand from the docs (https://nextjs.org/docs/app/building-your-application/optimizing/static-assets)
/ should point to the public folder
/ should point to the public folder
.tsx is source code, SVG files should use the .svg extension if you plan to serve them and use in the HTML tags. the link you shared shows a string as the path of an image tag, which is a different path type from imports and follows a different logic:- file imports at the top of the file represent paths on the filesystem
- the path on src props represent an address to a resource being served from a web server
Laysan AlbatrossOP
Yeah for sure it's source code but not in the classic sense 😄
I'm using it that way so I can have the logo in one file, but separate it in the 3 components, because I need to animate just parts of it.
I'm using it that way so I can have the logo in one file, but separate it in the 3 components, because I need to animate just parts of it.
So I don't need to protect it, I even want people to be able to access it.
@Rafael Almeida `.tsx` is source code, SVG files should use the `.svg` extension if you plan to serve them and use in the HTML tags. the link you shared shows a string as the path of an image tag, which is a different path type from imports and follows a different logic:
- file imports at the top of the file represent paths on the _filesystem_
- the path on src props represent an address to a resource being served from a web server
Laysan AlbatrossOP
Ahhh. That makes sense. Thanks a lot
But how would I access the public folder in an import?
@public probably hm?
@Laysan Albatross But how would I access the public folder in an import?
@ starts at /src (if any) or at / (if not using src folder) so i think just use ../../.. untill you arrive at the public folderLaysan AlbatrossOP
I did it with @/public now
seems to work
o nice
Sun bear
you may want to check if you imported as default or normal
Laysan AlbatrossOP
export const B2BRSchrift = () => {
not as default
@Laysan Albatross But how would I access the public folder in an import?
Sun bear
then try to check tsconfig.json, you will find the alias there
@Laysan Albatross seems to work
Sun bear
nvm, i didn't see this
Laysan AlbatrossOP
allgood thank u all 🙂