N
Nuxt5w ago
Wicker

Building a custom made nuxt 3 module

Hello people have a quick question which i'm not sure about and dont even know how to check. I'm trying to build a custom nuxt 3 module using this guide https://nuxt.com/docs/guide/going-further/modules On how to build guide it references *While building your module can be useful in some cases, most of the time you won't need to build it on your own: the playground takes care of it while developing, and the release script also has you covered when publishing. * The case is that i'm not publishing to npm and i want to use the module only for my own project. However when i deploy the main app ( with the module inside ) it seems everything works fine. So does that mean nuxt does that on it's own when building the main app or do i have to add a command to build the module before using?
2 Replies
kapa.ai
kapa.ai5w ago
Hi @Wicker. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- Based on the information provided in the knowledge sources, I can answer your question about building a custom Nuxt 3 module for your own project. When you're developing a custom Nuxt 3 module for your own project and not publishing it to npm, you generally don't need to build the module separately. Nuxt handles this process for you during the build of your main application. Here's what happens: 1. Local modules are automatically registered by Nuxt when they are placed in the modules/ directory of your project. As mentioned in the Nuxt documentation on directory structure (https://nuxt.com/docs/guide/directory-structure/modules), files matching the patterns modules/*/index.ts or modules/*.ts are auto-registered. 2. When you build your main application, Nuxt processes these local modules as part of the build process. This is why everything works fine when you deploy your main app with the module inside. 3. The nuxi build-module command, which is used to build Nuxt modules before publishing, is primarily intended for modules that will be distributed as npm packages. As stated in the Nuxt documentation (https://nuxt.com/docs/api/commands/build-module), this command generates a dist directory within your rootDir that contains the full build for your module. Since you're using the module only for your own project and not distributing it, you don't need to run a separate build command for the module. The fact that everything works fine when you deploy your main app indicates that Nuxt is handling the module correctly during the build process. However, if you do find a need to build your module separately for any reason, you can use the nuxi build-module command as described in the Nuxt documentation (https://nuxt.com/docs/api/commands/build-module). In summary, for a custom Nuxt 3 module used only in your own project, you don't need to add a separate command to build the module before using it. Nuxt takes care of this process when building the main application. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai5w ago
<@142400234444685312> Kapa.ai is still learning and improving, please let me know how I did by reacting below.
Want results from more Discord servers?
Add your server