diff --git a/README.md b/README.md index 1178611..1d78332 100644 --- a/README.md +++ b/README.md @@ -51,24 +51,32 @@ More info comming soon... ## Configuration It is possible to select which Nuxt modules will be activated in your project. All dependencies are being downloaded into local `node_modules`, but Nuxt build process will ensure only relevant packages will be bundled for production. -### UI +### UI preset It is possible to pick from three options: - `nuxt-ui` - full https://ui.nuxt.com/ via `@nuxt/ui` connector module **[RECOMMENDED]** - `tailwind` - only https://tailwindcss.com/ via `@nuxtjs/tailwindcss` connector module -- `off` - no UI library **[DEFAULT]** +- `off` - no UI library preset **[DEFAULT]** -Set the value via `NUXT_PUBLIC_IGNIS_UI` env variable. +Set the value via `NUXT_PUBLIC_IGNIS_PRESET_UI` env variable. -### Database +Value other than `off` will override Optional modules setting. + +### Database preset It is possible to pick from three options: - `neon` - https://neon.tech/ via `nuxt-neon` connector module **[RECOMMENDED]** - `supabase` - https://supabase.com/ via `@nuxtjs/supabase` connector module -- `off` - no database module **[DEFAULT]** +- `off` - no database module preset **[DEFAULT]** + +Set the value via `NUXT_PUBLIC_IGNIS_DB_PRESET` env variable. -Set the value via `NUXT_PUBLIC_IGNIS_DB` env variable. +Value other than `off` will override Optional modules setting. ### Optional modules Currently, following modules are opinionated: +- `@nuxt/ui` - set `NUXT_PUBLIC_IGNIS_UI` to `true | false` +- `@nuxtjs/tailwindcss` - set `NUXT_PUBLIC_IGNIS_TAILWIND` to `true | false` (ignored if `NUXT_PUBLIC_IGNIS_UI=true`) +- `nuxt-neon` - set `NUXT_PUBLIC_IGNIS_NEON` to `true | false` +- `@nuxtjs/supabase` - set `NUXT_PUBLIC_IGNIS_SUPABASE` to `true | false` - `@nuxtjs/i18n` - set `NUXT_PUBLIC_IGNIS_I18N` to `true | false` - `@formkit/nuxt` - set `NUXT_PUBLIC_IGNIS_FORMKIT` to `true | false` - `@nuxt/content` - set `NUXT_PUBLIC_IGNIS_CONTENT` to `true | false` diff --git a/features.ts b/features.ts index 3d7765e..5af27cf 100644 --- a/features.ts +++ b/features.ts @@ -1,10 +1,10 @@ import { defu } from 'defu' -import { log } from './utils/consola' import OpenProps from 'open-props' +import { log } from './utils/consola' export function setFeatures() { // list of optional extra features - let extras = [] as string[] + const extras = [] as string[] // object for optional config that will be merged with global Nuxt config // declared in nuxt.config.ts @@ -14,23 +14,22 @@ export function setFeatures() { // 1. default modules (mandatory) nuxtConfig.modules.push( - 'nuxt-time', - 'nuxt-security', - '@nuxt/eslint', - '@nuxt/image', - '@pinia/nuxt', - '@vueuse/nuxt', + 'nuxt-time', + 'nuxt-security', + '@nuxt/eslint', + '@nuxt/image', + '@pinia/nuxt', + '@vueuse/nuxt', ) // 2. optional modules // ui - if (process.env.NUXT_PUBLIC_IGNIS_UI === 'nuxt-ui') { + const uiPreset = process.env.NUXT_PUBLIC_IGNIS_PRESET_UI + if (uiPreset === 'nuxt-ui' || (!uiPreset && process.env.NUXT_PUBLIC_IGNIS_UI === 'true')) { nuxtConfig.modules.push('@nuxt/ui') - } - else { - // remove @nuxt/ui-specific components from resolution - // if module is not used + } else { + // remove @nuxt/ui-specific components from resolution if module is not used nuxtConfig = defu({ vue: { compilerOptions: { @@ -40,16 +39,17 @@ export function setFeatures() { }, nuxtConfig) // evaluate separate Tailwind CSS module - if (process.env.NUXT_PUBLIC_IGNIS_UI === 'tailwind') { + if (uiPreset === 'tailwind' || (!uiPreset && process.env.NUXT_PUBLIC_IGNIS_TAILWIND === 'true')) { nuxtConfig.modules.push('@nuxtjs/tailwindcss') } } // database - if (process.env.NUXT_PUBLIC_IGNIS_DB === 'neon') { + const dbPreset = process.env.NUXT_PUBLIC_IGNIS_PRESET_DB + if (dbPreset === 'neon' || (!dbPreset && process.env.NUXT_PUBLIC_IGNIS_NEON === 'true')) { // module definition nuxtConfig.modules.push('nuxt-neon') - } else if (process.env.NUXT_PUBLIC_IGNIS_DB === 'supabase') { + } else if (dbPreset === 'supabase' || (!dbPreset && process.env.NUXT_PUBLIC_IGNIS_SUPABASE === 'true')) { // module definition nuxtConfig.modules.push('@nuxtjs/supabase') // module-specific config key @@ -100,9 +100,9 @@ export function setFeatures() { } let overview = 'Nuxt Ignis will start using following settings:\n' - overview += 'Modules: ' + nuxtConfig.modules.join(', ') + "\n" + overview += 'Modules: ' + nuxtConfig.modules.join(', ') + '\n' if (extras.length > 0) { - overview += 'Extras: ' + extras.join(', ') + "\n" + overview += 'Extras: ' + extras.join(', ') + '\n' } log.info(overview) diff --git a/nuxt.config.ts b/nuxt.config.ts index eb24ec5..f05e55e 100644 --- a/nuxt.config.ts +++ b/nuxt.config.ts @@ -15,7 +15,7 @@ const nuxtConfig = defu(ignisFeatures, { stylistic: true, }, }, - + // app configuration runtimeConfig: { // nitro-only secret env-like variables go here @@ -26,8 +26,15 @@ const nuxtConfig = defu(ignisFeatures, { // NOTE: due to static-like nature of nuxt.config.ts file // actual values MUST BE provided via .env file (or production equivalent) ignis: { - ui: 'off', // nuxt-ui/tailwind/off - db: 'off', // neon/supabase/off + preset: { + ui: 'off', // nuxt-ui/tailwind/off + db: 'off', // neon/supabase/off + }, + // individual modules + ui: false, // true/false + tailwind: false, // true/false (ignored, if ui=true) + neon: false, // true/false + supabase: false, // true/false i18n: false, // true/false formkit: false, // true/false content: false, // true/false