[Vuejs]-Components auto imports in Nuxt 3 with modules

1👍

The answer was to make the same as in nuxt.config.ts:

from https://stackoverflow.com/a/66336654/10805872

So:

    // COMPONENTS
    "components:dirs"(dirs) {
      // Add ./components dir to the list
      dirs.push({
        path: path.resolve(__dirname, "./components"),
      });
    },

become:

    // COMPONENTS
    "components:dirs"(dirs) {
      // Add ./components dir to the list
      dirs.push({
        path: path.resolve(__dirname, "./components"), pathPrefix: false
      });
    },

With the prefix you have to use it, for example a component in modules/user/localeSwitcher.vue, as <user-locale-switcher />

Without prefix so pathPrefix: false, you can use directly <locale-switcher />

Leave a comment