#Storyblok Schema as Code - Nuxt Setup and Folder Structure
1 messages · Page 1 of 1 (latest)
Your approach of colocating component files (Vue, schema, types, etc.) within a single directory (e.g., app/storyblok/teaser/) is a solid organizational strategy and aligns well with modular, maintainable code practices. However, based on the knowledge sources provided, there is no official Nuxt or Nuxt Content documentation that directly addresses Storyblok "Schema as Code" setups or the use of import.meta.glob for schema management in this context.
Here’s what is relevant from the sources:
- Nuxt supports custom folder structures for arbitrary code, including types and utility files. You can create your own folders (like
/typesor/storyblok) and either import files manually or configure auto-imports via theimports.dirsoption innuxt.config.tsif you want auto-imports for certain directories. However, you must ensure your custom folders do not conflict with future Nuxt reserved folders. Manual imports are always safe and flexible for custom setups Where can arbitrary code be placed in Nuxt 3?. - There is no explicit documentation on using
import.meta.globfor schema files or on excluding such files from client bundles. Nuxt’s Vite integration allows you to use Vite plugins and advanced configuration, so a custom Vite plugin could be a solution for excluding files from the client bundle, but this is not covered in the official docs Using Vite Plugins in Nuxt. - The Nuxt Content module and Studio provide schema-based content management, but this is focused on content collections and app config schemas, not Storyblok schemas or external CMS schema management Defining Collections, Customize edition.
Summary of best practices based on available information:
- Colocating related files (component, schema, types) is a maintainable approach and supported by Nuxt’s flexible directory structure.
- You can use
import.meta.globto gather files for server-side scripts, but you’ll need to ensure these files are not included in the client bundle. This may require custom Vite configuration, which is possible but not documented in the official Nuxt sources. - Manual imports and custom folders are safe, but be mindful of potential future folder name conflicts with Nuxt.
- There is no official Nuxt or Nuxt Content support or guidance for Storyblok schema management as code, so your approach is custom and community-driven.
If you need to ensure files are excluded from the client bundle, you may need to experiment with Vite’s build.rollupOptions or a custom plugin, but the knowledge sources do not provide a ready-made solution for this.
If you want to share or discuss your approach further, the Nuxt community (GitHub Discussions, Discord) may have more real-world examples and advice.