can I use @ or ~ alias in route.ts file? #10222
Unanswered
flysky9981
asked this question in
Q&A
Replies: 1 comment 3 replies
-
If I'm not wrong, the routes.ts file runs at the same env of the vite.config where import aliases are not supported. |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I set the alias of "./app" to "~" in vite.config.js file using the code below:
export default defineConfig({ resolve: { alias: { "~": resolve(__dirname, "./app"), } },
and using the alias in route.ts file as below:
import {allRoutes} from "~/routes-custom";
but when i " npm run dev" in the terminal, the "remix" says:
`23:11:56 [remix] Route config in "routes.ts" is invalid.
Error: Failed to load url ~/routes-custom (resolved id: ~/routes-custom) in D:/home4dev/devjoe-dir/remix-antd-admin-master/app/routes.ts. Does the file exist?
`
when I change the
import {allRoutes} from "~/routes-custom";
toimport {allRoutes} from "./routes-custom";
it works. so what's wrong with this?Beta Was this translation helpful? Give feedback.
All reactions