Another super video! You can also add to your Vs code settings these lines: "typescript.updateImportsOnFileMove.enabled": "always" To get vs code to automatically update the file path. (Obviously replacing with JavaScript if your project isn't using ts)
The best way to also explain it is that import aliases changes your RELATIVE import declarations to ABSOLUTE imports so that way its always starting from the same point, which is why it works!
And thanks to Dante for calling out my error in my previous video 🤦♂! I literally have like 20 projects right now on my computer using js imports and just had a brain fart last night when recording quickly since I've been using it in TS.
You might want to look into using barrel files, that would simplify your import statements. Currently: import Heading from "@ui/Heading.astro": import Section from "@ui/Section.astro"; Using barrel files: import { Heading, Section } from "@ui/index"
Could you make astro tutorial about how to render multiple array images in mdx and astro file with react component like passing images array to the component to render or something?
Next js supports it out-of-box feature.....And Nust js don't need to import anything....how crazy is that🌰🌰🌰BTW your Vscode file icon themes seem cool in Astro Stack......🎉
Because it’s always starting at the root path, it will be consistent. References to that file will need to be updated (which many IDEs will update automatically, but the big advantage is that when referencing other files, you don’t have to traverse and figure out what level everything us at. Components are always @components, for instance.
Another super video!
You can also add to your Vs code settings these lines:
"typescript.updateImportsOnFileMove.enabled": "always"
To get vs code to automatically update the file path. (Obviously replacing with JavaScript if your project isn't using ts)
Oh, cool! I know some of my extensions do that, but didn't know there was a VSCode setting. I'll add it! Thanks!
The best way to also explain it is that import aliases changes your RELATIVE import declarations to ABSOLUTE imports so that way its always starting from the same point, which is why it works!
And thanks to Dante for calling out my error in my previous video 🤦♂! I literally have like 20 projects right now on my computer using js imports and just had a brain fart last night when recording quickly since I've been using it in TS.
You might want to look into using barrel files, that would simplify your import statements.
Currently:
import Heading from "@ui/Heading.astro":
import Section from "@ui/Section.astro";
Using barrel files:
import { Heading, Section } from "@ui/index"
Yes! Great addition!
you can put only:
import { Header, Section } from "@ui"
you can omit index!
ooo, you gotta add this to your new Astro course 💥 🚀 😎 👍
Done ☺️
thanks this was exactly what i was looking for in astro as i was using path aliase in nextjs
Aliases are the best!
I have tried, this doesnt work with create-react-app. The reason may typescript has removed this support.
Can you please confirm on this.
Good work, I love your way of teaching!
Glad to hear that!
Could you make astro tutorial about how to render multiple array images in mdx and astro file with react component like passing images array to the component to render or something?
Another useful video from Chris, no surprises here. :)
Thanks, my friend 🙏
Fantastic, thank you 🙏🏼
Glad you enjoyed it!
nice! What is the theme u are using?
I think community material theme?
Not working in express app with js
Hmm. What problems are you having?
Wow 😂 finally seeing your face for the first time this year 😂 you look beautiful 😍😅
lol um thanks? 💁♂️ 💅
good one!
Thank you! Cheers!
What about unit tests?
The aliases should still work? Are you having problems with them?
Next js supports it out-of-box feature.....And Nust js don't need to import anything....how crazy is that🌰🌰🌰BTW your Vscode file icon themes seem cool in Astro Stack......🎉
Yep, Next asks you if it can just set it up out of the box. I would love for the Astro CLI to do this personally (or enable it with a flag?)
Thanks man
You’re welcome!
Aliases are cool, but they don't solve the issue you're talking about of moving a file, they're just another way to represent the same path, no?
Because it’s always starting at the root path, it will be consistent. References to that file will need to be updated (which many IDEs will update automatically, but the big advantage is that when referencing other files, you don’t have to traverse and figure out what level everything us at. Components are always @components, for instance.