@dynect/base 0.18.1 → 0.19.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/module.ts +21 -4
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dynect/base",
3
- "version": "0.18.1",
3
+ "version": "0.19.0",
4
4
  "description": "Reusable Nuxt base module — components, composables, utils, plugins and i18n from the Dynect design system.",
5
5
  "type": "module",
6
6
  "license": "MIT",
package/src/module.ts CHANGED
@@ -1,4 +1,6 @@
1
1
  import { addComponentsDir, addImports, addImportsDir, addPlugin, createResolver, defineNuxtModule, installModule } from '@nuxt/kit';
2
+ import tailwindcss from '@tailwindcss/vite';
3
+ import { defu } from 'defu';
2
4
  import { existsSync } from 'node:fs';
3
5
  import { join } from 'node:path';
4
6
 
@@ -24,6 +26,8 @@ export interface DynectBaseOptions {
24
26
  /** Enable SSR width plugin. Default: true */
25
27
  ssrWidth?: boolean;
26
28
  };
29
+ /** Auto-register @tailwindcss/vite Vite plugin. Set false to disable (e.g. if already configured in nuxt.config). Default: true */
30
+ tailwind?: boolean;
27
31
  }
28
32
 
29
33
  const DIR_CONFIGS: Record<string, { prefix: string }> = {
@@ -42,6 +46,7 @@ export default defineNuxtModule<DynectBaseOptions>({
42
46
  defaults: {
43
47
  dirs: ['dynect', 'ui', 'base', 'chart'],
44
48
  global: true,
49
+ tailwind: true,
45
50
  veeValidate: {},
46
51
  colorMode: {},
47
52
  i18n: {},
@@ -100,10 +105,22 @@ export default defineNuxtModule<DynectBaseOptions>({
100
105
  config.resolve.alias.unshift(...entries);
101
106
  } else {
102
107
  const existing = config.resolve.alias ?? {};
103
- config.resolve.alias = [
104
- ...entries,
105
- ...Object.entries(existing).map(([find, replacement]) => ({ find, replacement })),
106
- ];
108
+ config.resolve.alias = [...entries, ...Object.entries(existing).map(([find, replacement]) => ({ find, replacement }))];
109
+ }
110
+ });
111
+ }
112
+
113
+ // ── Tailwind CSS v4 ──────────────────────────────────────────────────────
114
+ // Add @tailwindcss/vite plugin unless disabled or already present.
115
+ // "Already present" check: look for any plugin named @tailwindcss/vite:*
116
+ // so we don't double-process if the consuming app added it manually.
117
+ if (options.tailwind !== false) {
118
+ nuxt.hook('vite:extendConfig', (config) => {
119
+ const c = config as any;
120
+ const flat = [...(c.plugins ?? [])].flat().filter(Boolean) as { name?: string }[];
121
+ const alreadyAdded = flat.some((p) => typeof p.name === 'string' && p.name.startsWith('@tailwindcss/vite'));
122
+ if (!alreadyAdded) {
123
+ c.plugins = [...(c.plugins ?? []), tailwindcss()];
107
124
  }
108
125
  });
109
126
  }