Is there a way to set custom auto imports in Nuxt 3? I use Pinia and my stores are in the root directory under /stores.
For example, if I want to use the store from /stores/auth.store.ts in a component, I always have to import the store like this:
import { useCourseStore } from '~~/stores/course.store';
.
As defined on Pinia doc https://pinia.vuejs.org/ssr/nuxt.html#auto-imports, you can set this config in your nuxt.config.ts
export default defineNuxtConfig({
// your config...
modules: [
[
'@pinia/nuxt',
{ autoImports: ['defineStore'] },
],
],
});
And you can also define custom import dirs in your config https://nuxt.com/docs/api/configuration/nuxt-config#imports
export default defineNuxtConfig({
// your config
imports: {
dirs: ['stores'],
},
});