@dynect/base 0.8.1 → 0.10.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 +9 -31
package/package.json
CHANGED
package/src/module.ts
CHANGED
|
@@ -1,12 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
addComponentsDir,
|
|
3
|
-
addImports,
|
|
4
|
-
addImportsDir,
|
|
5
|
-
addPlugin,
|
|
6
|
-
createResolver,
|
|
7
|
-
defineNuxtModule,
|
|
8
|
-
installModule,
|
|
9
|
-
} from '@nuxt/kit';
|
|
1
|
+
import { addComponentsDir, addImports, addImportsDir, addPlugin, createResolver, defineNuxtModule, installModule } from '@nuxt/kit';
|
|
10
2
|
import { existsSync } from 'node:fs';
|
|
11
3
|
import { join } from 'node:path';
|
|
12
4
|
|
|
@@ -80,8 +72,7 @@ export default defineNuxtModule<DynectBaseOptions>({
|
|
|
80
72
|
// @/lib/utils → runtime/lib/utils (when not present in consuming app)
|
|
81
73
|
// This one works via nuxt.options.alias because lib/utils is not prefixed with @
|
|
82
74
|
if (!existsSync(join(srcDir, 'lib', 'utils.ts'))) {
|
|
83
|
-
nuxt.options.alias[join(srcDir, 'lib', 'utils')] =
|
|
84
|
-
resolver.resolve('./runtime/lib/utils');
|
|
75
|
+
nuxt.options.alias[join(srcDir, 'lib', 'utils')] = resolver.resolve('./runtime/lib/utils');
|
|
85
76
|
}
|
|
86
77
|
|
|
87
78
|
// @/components/ui/* → runtime/components/ui/*
|
|
@@ -96,22 +87,17 @@ export default defineNuxtModule<DynectBaseOptions>({
|
|
|
96
87
|
const entry = { find: /^[@~]\/components\/ui/, replacement: uiRuntimePath };
|
|
97
88
|
|
|
98
89
|
if (Array.isArray(config.resolve.alias)) {
|
|
99
|
-
|
|
90
|
+
config.resolve.alias.unshift(entry);
|
|
100
91
|
} else {
|
|
101
92
|
const existing = config.resolve.alias ?? {};
|
|
102
|
-
config.resolve.alias = [
|
|
103
|
-
entry,
|
|
104
|
-
...Object.entries(existing).map(([find, replacement]) => ({ find, replacement })),
|
|
105
|
-
];
|
|
93
|
+
config.resolve.alias = [entry, ...Object.entries(existing).map(([find, replacement]) => ({ find, replacement }))];
|
|
106
94
|
}
|
|
107
95
|
});
|
|
108
96
|
}
|
|
109
97
|
|
|
110
98
|
// ── Install required Nuxt modules ────────────────────────────────────────
|
|
111
99
|
if (options.shadcn !== false) {
|
|
112
|
-
const shadcnComponentDir = isStandalone
|
|
113
|
-
? join(runtimeComponentsDir, 'ui')
|
|
114
|
-
: '~/components/ui';
|
|
100
|
+
const shadcnComponentDir = isStandalone ? join(runtimeComponentsDir, 'ui') : '~/components/ui';
|
|
115
101
|
|
|
116
102
|
await installModule('shadcn-nuxt', {
|
|
117
103
|
prefix: '',
|
|
@@ -137,9 +123,7 @@ export default defineNuxtModule<DynectBaseOptions>({
|
|
|
137
123
|
}
|
|
138
124
|
|
|
139
125
|
if (options.i18n !== false) {
|
|
140
|
-
const langDir = isStandalone
|
|
141
|
-
? resolver.resolve('./runtime/assets/lang')
|
|
142
|
-
: resolver.resolve('../../../app/assets/lang');
|
|
126
|
+
const langDir = isStandalone ? resolver.resolve('./runtime/assets/lang') : resolver.resolve('../../../app/assets/lang');
|
|
143
127
|
|
|
144
128
|
await installModule('@nuxtjs/i18n', {
|
|
145
129
|
locales: [
|
|
@@ -175,9 +159,7 @@ export default defineNuxtModule<DynectBaseOptions>({
|
|
|
175
159
|
await installModule('@pinia/nuxt');
|
|
176
160
|
|
|
177
161
|
// ── CSS ──────────────────────────────────────────────────────────────────
|
|
178
|
-
const cssPath = isStandalone
|
|
179
|
-
? resolver.resolve('./runtime/assets/css/main.css')
|
|
180
|
-
: resolver.resolve('../../../app/assets/css/main.css');
|
|
162
|
+
const cssPath = isStandalone ? resolver.resolve('./runtime/assets/css/main.css') : resolver.resolve('../../../app/assets/css/main.css');
|
|
181
163
|
|
|
182
164
|
if (existsSync(cssPath)) {
|
|
183
165
|
nuxt.options.css.unshift(cssPath);
|
|
@@ -197,18 +179,14 @@ export default defineNuxtModule<DynectBaseOptions>({
|
|
|
197
179
|
}
|
|
198
180
|
|
|
199
181
|
// ── Composables ──────────────────────────────────────────────────────────
|
|
200
|
-
const composablesPath = isStandalone
|
|
201
|
-
? resolver.resolve('./runtime/composables')
|
|
202
|
-
: resolver.resolve('../../../app/composables');
|
|
182
|
+
const composablesPath = isStandalone ? resolver.resolve('./runtime/composables') : resolver.resolve('../../../app/composables');
|
|
203
183
|
|
|
204
184
|
if (existsSync(composablesPath)) {
|
|
205
185
|
addImportsDir(composablesPath);
|
|
206
186
|
}
|
|
207
187
|
|
|
208
188
|
// ── Utils ────────────────────────────────────────────────────────────────
|
|
209
|
-
const utilsPath = isStandalone
|
|
210
|
-
? resolver.resolve('./runtime/utils')
|
|
211
|
-
: resolver.resolve('../../../app/utils');
|
|
189
|
+
const utilsPath = isStandalone ? resolver.resolve('./runtime/utils') : resolver.resolve('../../../app/utils');
|
|
212
190
|
|
|
213
191
|
if (existsSync(utilsPath)) {
|
|
214
192
|
addImportsDir(utilsPath);
|