I want to use modules (so not the default structure directories) with Nuxt, something like that:
The problem is that I don't know how to configure Nuxt or my module to auto import the components in nested folders like the Card
folders. For example the PlanChoiceCard.vue
component is auto imported but not NestedComponent.vue
This is my nuxt.config.js
:
import { defineNuxtConfig } from "nuxt";
export default defineNuxtConfig({
ssr: true,
ignore: ["node_modules/**/*"],
plugins: ["~/plugins/vue-i18n.client.ts"],
runtimeConfig: {
public: {
myapp: {
version: "1.7.8.2",
},
},
},
modules: ["./modules/Plans"],
build: {
postcss: {
postcssOptions: {
plugins: {
tailwindcss: {},
autoprefixer: {},
},
},
},
},
css: ["~/assets/css/tailwind.css"],
});
and the configuration of the Plans
module:
import path from "path";
import { defineNuxtModule } from "@nuxt/kit";
export default defineNuxtModule({
// Default configuration options for your module
defaults: {},
hooks: {
// ROUTES
"pages:extend"(pages) {
pages.push({
name: "user",
path: "/",
file: path.resolve(__dirname, "./views/PlanChoices.vue"),
});
},
// COMPONENTS
"components:dirs"(dirs) {
// Add ./components dir to the list
dirs.push({
path: path.resolve(__dirname, "./components"),
});
},
// COMPOSABLES
// "autoImports:dirs"(dirs) {
// dirs.push(path.resolve(__dirname, "./composables"));
// },
},
async setup(moduleOptions, nuxt) {
// -- Add your module logic here --
},
});