@dynect/base 0.8.0 → 0.9.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 +28 -43
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,38 +72,39 @@ 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/*
|
|
88
79
|
// Must run BEFORE @ is resolved, so we use a regex alias in vite:extendConfig.
|
|
89
80
|
// Only applied when the consuming app has no own components/ui directory.
|
|
90
|
-
if (isStandalone && !existsSync(join(srcDir, 'components', 'ui'))) {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
}
|
|
81
|
+
// if (isStandalone && !existsSync(join(srcDir, 'components', 'ui'))) {
|
|
82
|
+
// const uiRuntimePath = join(runtimeComponentsDir, 'ui');
|
|
83
|
+
|
|
84
|
+
// nuxt.hook('vite:extendConfig', (config) => {
|
|
85
|
+
// config.resolve ??= {};
|
|
86
|
+
|
|
87
|
+
// const entry = { find: /^[@~]\/components\/ui/, replacement: uiRuntimePath };
|
|
88
|
+
|
|
89
|
+
// if (Array.isArray(config.resolve.alias)) {
|
|
90
|
+
// (config.resolve.alias as any[]).unshift(entry);
|
|
91
|
+
// } else {
|
|
92
|
+
// const existing = config.resolve.alias ?? {};
|
|
93
|
+
// config.resolve.alias = [
|
|
94
|
+
// entry,
|
|
95
|
+
// ...Object.entries(existing).map(([find, replacement]) => ({ find, replacement })),
|
|
96
|
+
// ];
|
|
97
|
+
// }
|
|
98
|
+
// });
|
|
99
|
+
// }
|
|
109
100
|
|
|
110
101
|
// ── Install required Nuxt modules ────────────────────────────────────────
|
|
111
102
|
if (options.shadcn !== false) {
|
|
103
|
+
const shadcnComponentDir = isStandalone ? join(runtimeComponentsDir, 'ui') : '~/components/ui';
|
|
104
|
+
|
|
112
105
|
await installModule('shadcn-nuxt', {
|
|
113
106
|
prefix: '',
|
|
114
|
-
componentDir:
|
|
107
|
+
componentDir: shadcnComponentDir,
|
|
115
108
|
...options.shadcn,
|
|
116
109
|
});
|
|
117
110
|
}
|
|
@@ -133,9 +126,7 @@ export default defineNuxtModule<DynectBaseOptions>({
|
|
|
133
126
|
}
|
|
134
127
|
|
|
135
128
|
if (options.i18n !== false) {
|
|
136
|
-
const langDir = isStandalone
|
|
137
|
-
? resolver.resolve('./runtime/assets/lang')
|
|
138
|
-
: resolver.resolve('../../../app/assets/lang');
|
|
129
|
+
const langDir = isStandalone ? resolver.resolve('./runtime/assets/lang') : resolver.resolve('../../../app/assets/lang');
|
|
139
130
|
|
|
140
131
|
await installModule('@nuxtjs/i18n', {
|
|
141
132
|
locales: [
|
|
@@ -171,9 +162,7 @@ export default defineNuxtModule<DynectBaseOptions>({
|
|
|
171
162
|
await installModule('@pinia/nuxt');
|
|
172
163
|
|
|
173
164
|
// ── CSS ──────────────────────────────────────────────────────────────────
|
|
174
|
-
const cssPath = isStandalone
|
|
175
|
-
? resolver.resolve('./runtime/assets/css/main.css')
|
|
176
|
-
: resolver.resolve('../../../app/assets/css/main.css');
|
|
165
|
+
const cssPath = isStandalone ? resolver.resolve('./runtime/assets/css/main.css') : resolver.resolve('../../../app/assets/css/main.css');
|
|
177
166
|
|
|
178
167
|
if (existsSync(cssPath)) {
|
|
179
168
|
nuxt.options.css.unshift(cssPath);
|
|
@@ -193,18 +182,14 @@ export default defineNuxtModule<DynectBaseOptions>({
|
|
|
193
182
|
}
|
|
194
183
|
|
|
195
184
|
// ── Composables ──────────────────────────────────────────────────────────
|
|
196
|
-
const composablesPath = isStandalone
|
|
197
|
-
? resolver.resolve('./runtime/composables')
|
|
198
|
-
: resolver.resolve('../../../app/composables');
|
|
185
|
+
const composablesPath = isStandalone ? resolver.resolve('./runtime/composables') : resolver.resolve('../../../app/composables');
|
|
199
186
|
|
|
200
187
|
if (existsSync(composablesPath)) {
|
|
201
188
|
addImportsDir(composablesPath);
|
|
202
189
|
}
|
|
203
190
|
|
|
204
191
|
// ── Utils ────────────────────────────────────────────────────────────────
|
|
205
|
-
const utilsPath = isStandalone
|
|
206
|
-
? resolver.resolve('./runtime/utils')
|
|
207
|
-
: resolver.resolve('../../../app/utils');
|
|
192
|
+
const utilsPath = isStandalone ? resolver.resolve('./runtime/utils') : resolver.resolve('../../../app/utils');
|
|
208
193
|
|
|
209
194
|
if (existsSync(utilsPath)) {
|
|
210
195
|
addImportsDir(utilsPath);
|