@dynect/base 0.10.4 → 0.11.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.
- package/package.json +1 -1
- package/src/module.ts +45 -58
package/package.json
CHANGED
package/src/module.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { addComponentsDir, addImports, addImportsDir, addPlugin, createResolver, defineNuxtModule, installModule } from '@nuxt/kit';
|
|
2
|
-
import { defu } from 'defu';
|
|
3
2
|
import { existsSync } from 'node:fs';
|
|
4
3
|
import { join } from 'node:path';
|
|
5
4
|
|
|
@@ -46,7 +45,7 @@ export default defineNuxtModule<DynectBaseOptions>({
|
|
|
46
45
|
veeValidate: {},
|
|
47
46
|
colorMode: {},
|
|
48
47
|
i18n: {},
|
|
49
|
-
shadcn: {
|
|
48
|
+
shadcn: {},
|
|
50
49
|
icon: {},
|
|
51
50
|
plugins: { toast: true, ssrWidth: true },
|
|
52
51
|
},
|
|
@@ -97,78 +96,66 @@ export default defineNuxtModule<DynectBaseOptions>({
|
|
|
97
96
|
}
|
|
98
97
|
|
|
99
98
|
// ── Install required Nuxt modules ────────────────────────────────────────
|
|
100
|
-
// installModule is marked @deprecated in @nuxt/kit but is the only practical
|
|
101
|
-
// API for installing sub-modules with dynamic options during a module's setup.
|
|
102
99
|
if (options.shadcn !== false) {
|
|
103
|
-
|
|
104
|
-
// defu from always populating it, which would override the computed path.
|
|
105
|
-
const { componentDir: userComponentDir, ...shadcnRest } = (options.shadcn ?? {}) as { prefix?: string; componentDir?: string };
|
|
106
|
-
const shadcnComponentDir = userComponentDir ?? (isStandalone ? join(runtimeComponentsDir, 'ui') : '~/components/ui');
|
|
100
|
+
const shadcnComponentDir = isStandalone ? join(runtimeComponentsDir, 'ui') : '~/components/ui';
|
|
107
101
|
|
|
108
|
-
await installModule('shadcn-nuxt', {
|
|
102
|
+
await installModule('shadcn-nuxt', {
|
|
103
|
+
prefix: '',
|
|
104
|
+
componentDir: shadcnComponentDir,
|
|
105
|
+
});
|
|
109
106
|
}
|
|
110
107
|
|
|
111
108
|
if (options.veeValidate !== false) {
|
|
112
|
-
await installModule('@vee-validate/nuxt', options.veeValidate ?? {});
|
|
109
|
+
await installModule('@vee-validate/nuxt', options.veeValidate ?? {});
|
|
113
110
|
}
|
|
114
111
|
|
|
115
112
|
if (options.colorMode !== false) {
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
'
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
storage: 'cookie',
|
|
126
|
-
storageKey: 'dynect_color_mode',
|
|
127
|
-
})
|
|
128
|
-
);
|
|
113
|
+
await installModule('@nuxtjs/color-mode', {
|
|
114
|
+
preference: 'system',
|
|
115
|
+
fallback: 'light',
|
|
116
|
+
classPrefix: '',
|
|
117
|
+
classSuffix: '',
|
|
118
|
+
storage: 'cookie',
|
|
119
|
+
storageKey: 'dynect_color_mode',
|
|
120
|
+
...options.colorMode,
|
|
121
|
+
});
|
|
129
122
|
}
|
|
130
123
|
|
|
131
124
|
if (options.i18n !== false) {
|
|
132
125
|
const langDir = isStandalone ? resolver.resolve('./runtime/assets/lang') : resolver.resolve('../../../app/assets/lang');
|
|
133
126
|
|
|
134
|
-
await installModule(
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
},
|
|
152
|
-
})
|
|
153
|
-
);
|
|
127
|
+
await installModule('@nuxtjs/i18n', {
|
|
128
|
+
locales: [
|
|
129
|
+
{ code: 'en', iso: 'en_US', file: 'en.json', name: 'English' },
|
|
130
|
+
{ code: 'ms', iso: 'ms_MY', file: 'ms.json', name: 'Bahasa' },
|
|
131
|
+
],
|
|
132
|
+
langDir,
|
|
133
|
+
defaultLocale: 'en',
|
|
134
|
+
strategy: 'no_prefix',
|
|
135
|
+
detectBrowserLanguage: {
|
|
136
|
+
useCookie: true,
|
|
137
|
+
cookieKey: 'dynect_language',
|
|
138
|
+
cookieSecure: true,
|
|
139
|
+
redirectOn: 'root',
|
|
140
|
+
alwaysRedirect: true,
|
|
141
|
+
},
|
|
142
|
+
...options.i18n,
|
|
143
|
+
});
|
|
154
144
|
}
|
|
155
145
|
|
|
156
146
|
if (options.icon !== false) {
|
|
157
|
-
await installModule(
|
|
158
|
-
'
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
},
|
|
167
|
-
})
|
|
168
|
-
);
|
|
147
|
+
await installModule('@nuxt/icon', {
|
|
148
|
+
provider: 'server',
|
|
149
|
+
mode: 'svg',
|
|
150
|
+
serverBundle: {
|
|
151
|
+
collections: ['heroicons', 'lucide', 'mdi'],
|
|
152
|
+
remote: false,
|
|
153
|
+
},
|
|
154
|
+
...options.icon,
|
|
155
|
+
});
|
|
169
156
|
}
|
|
170
157
|
|
|
171
|
-
await installModule('@pinia/nuxt');
|
|
158
|
+
await installModule('@pinia/nuxt');
|
|
172
159
|
|
|
173
160
|
// ── CSS ──────────────────────────────────────────────────────────────────
|
|
174
161
|
const cssPath = isStandalone ? resolver.resolve('./runtime/assets/css/main.css') : resolver.resolve('../../../app/assets/css/main.css');
|
|
@@ -178,13 +165,13 @@ export default defineNuxtModule<DynectBaseOptions>({
|
|
|
178
165
|
}
|
|
179
166
|
|
|
180
167
|
// ── Components ───────────────────────────────────────────────────────────
|
|
181
|
-
for (const dir of options.dirs) {
|
|
168
|
+
for (const dir of options.dirs!) {
|
|
182
169
|
const dirPath = join(componentsBase, dir);
|
|
183
170
|
if (!existsSync(dirPath)) continue;
|
|
184
171
|
|
|
185
172
|
addComponentsDir({
|
|
186
173
|
path: dirPath,
|
|
187
|
-
prefix: DIR_CONFIGS[dir]
|
|
174
|
+
prefix: DIR_CONFIGS[dir]!.prefix,
|
|
188
175
|
pathPrefix: false,
|
|
189
176
|
global: options.global,
|
|
190
177
|
});
|