You can apply aliases to your deno.json file. This makes imports easier to maintain in projects. Worry less about many ../ levels deep you're in or if you're to ever move a file to a different level.
Example:
{
"imports": {
"@components/*": "./src/components/*",
"@layouts/*": "./src/layouts/*",
"@pages/*": "./src/pages/*",
"@styles/*": "./src/styles/*"
}
}
Now if we import our Base layout and components, we'll do so like this:
import Base from "@layouts/Base.tsx"
import Card from "@components/Card.tsx"
import SidebarItem from "@components/sidebar/Item.tsx"
You could also create a catch-all alias:
{
"imports": {
"@/": "./src/"
}
}
With the catch-all alias, you'd just use @/layouts/Base.tsx.
