When trying to importing files through aliases at the configuration (nuxt.config.ts), an error occurs: Cannot find module '~/....
There is an example: codesnadbox.io
Short example
nuxt.config.ts
import { book } from "~/vars";
export default defineNuxtConfig({
runtimeConfig: {
bookApiEndpoint: book.apiEndpoint || "",
},
});
Full example
If use an absolute path, then file will be imported:
import { book } from "./vars";
But if there is another import through the alias inside the file, then there will be an error again (pic.1):
./vars.ts
export * from "~/entities";
./entities/index.ts
export * from "./book";
./entities/book.ts
export const book = {
apiEndpoint: '/api/book'
}
There is an example: codesnadbox.io
Question
How can aliases be used inside a config file?
Thank you in advance!
There is an example: codesnadbox.io