@mframework/ui 0.0.6-beta5 → 0.0.6-beta6
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/module.ts +18 -84
- package/package.json +1 -1
package/module.ts
CHANGED
|
@@ -9,18 +9,17 @@ import {
|
|
|
9
9
|
} from '@nuxt/kit'
|
|
10
10
|
|
|
11
11
|
export interface MFrameworkUiOptions {
|
|
12
|
-
image
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
enable ? : boolean
|
|
12
|
+
image?: Record<string, any>
|
|
13
|
+
fonts?: Record<string, any>
|
|
14
|
+
vuetify?: {
|
|
15
|
+
vuetifyOptions?: Record<string, any>
|
|
16
|
+
}
|
|
17
|
+
tailwind?: {
|
|
18
|
+
enable?: boolean
|
|
20
19
|
}
|
|
21
20
|
}
|
|
22
21
|
|
|
23
|
-
export default defineNuxtModule
|
|
22
|
+
export default defineNuxtModule<MFrameworkUiOptions>({
|
|
24
23
|
meta: {
|
|
25
24
|
name: '@mframework/ui',
|
|
26
25
|
configKey: 'mframeworkUi'
|
|
@@ -39,10 +38,9 @@ export default defineNuxtModule < MFrameworkUiOptions > ({
|
|
|
39
38
|
enable: true
|
|
40
39
|
}
|
|
41
40
|
},
|
|
41
|
+
|
|
42
42
|
async setup(options, nuxt) {
|
|
43
|
-
const {
|
|
44
|
-
resolve
|
|
45
|
-
} = createResolver(import.meta.url)
|
|
43
|
+
const { resolve } = createResolver(import.meta.url)
|
|
46
44
|
|
|
47
45
|
//
|
|
48
46
|
// 1. Expose options to runtime
|
|
@@ -50,89 +48,25 @@ export default defineNuxtModule < MFrameworkUiOptions > ({
|
|
|
50
48
|
nuxt.options.runtimeConfig.public.mframeworkUi = options
|
|
51
49
|
|
|
52
50
|
//
|
|
53
|
-
//
|
|
51
|
+
// 2. Install @nuxt/fonts
|
|
54
52
|
//
|
|
55
53
|
await installModule('@nuxt/fonts', options.fonts || {})
|
|
56
54
|
|
|
57
55
|
//
|
|
58
|
-
//
|
|
56
|
+
// 3. Install Vuetify via vuetify-nuxt-module (optional).
|
|
59
57
|
// First check whether the consuming project actually has `vuetify`
|
|
60
58
|
// installed to avoid Nuxt failing during module resolution.
|
|
61
59
|
//
|
|
62
|
-
let
|
|
60
|
+
let vuetifyModulePath: string | null = null
|
|
63
61
|
try {
|
|
64
|
-
|
|
65
|
-
// without triggering Nuxt's module loader.
|
|
66
|
-
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
67
|
-
const {
|
|
68
|
-
createRequire
|
|
69
|
-
} = await import('module')
|
|
70
|
-
const req = createRequire(import.meta.url)
|
|
71
|
-
try {
|
|
72
|
-
req.resolve('vuetify')
|
|
73
|
-
// Vuetify is present in the project's node_modules. We won't call
|
|
74
|
-
// `installModule` here to avoid forcing Nuxt to load the module
|
|
75
|
-
// during `nuxt prepare` (which can fail in some install environments).
|
|
76
|
-
vuetifyInstalled = true
|
|
77
|
-
} catch (e) {
|
|
78
|
-
// Vuetify not found — skip installing the module
|
|
79
|
-
// eslint-disable-next-line no-console
|
|
80
|
-
console.warn('@mframework/ui: Vuetify not found in project dependencies; skipping Vuetify integration.')
|
|
81
|
-
}
|
|
62
|
+
vuetifyModulePath = resolveModule('vuetify-nuxt-module', { paths: [nuxt.options.modulesDir] })
|
|
82
63
|
} catch (err) {
|
|
83
|
-
//
|
|
84
|
-
|
|
85
|
-
console.warn('@mframework/ui: Failed to detect Vuetify availability; skipping Vuetify integration.')
|
|
86
|
-
vuetifyInstalled = false
|
|
64
|
+
// Module not found, skip Vuetify installation
|
|
65
|
+
console.warn('[mframework-ui] Vuetify not found, skipping Vuetify setup.')
|
|
87
66
|
}
|
|
88
67
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
//
|
|
92
|
-
if (options.tailwind?.enable !== false) {
|
|
93
|
-
nuxt.options.css = nuxt.options.css || []
|
|
94
|
-
nuxt.options.css.push(resolve('./runtime/assets/css/tailwind.css'))
|
|
95
|
-
|
|
96
|
-
nuxt.options.postcss = nuxt.options.postcss || {
|
|
97
|
-
plugins: {},
|
|
98
|
-
order: []
|
|
99
|
-
}
|
|
100
|
-
nuxt.options.postcss.plugins = nuxt.options.postcss.plugins || {}
|
|
101
|
-
// Use the new PostCSS adapter package name so Nuxt doesn't try to
|
|
102
|
-
// use the old `tailwindcss` package as a PostCSS plugin.
|
|
103
|
-
nuxt.options.postcss.plugins['@tailwindcss/postcss'] = {}
|
|
104
|
-
nuxt.options.postcss.plugins['autoprefixer'] = {}
|
|
105
|
-
|
|
106
|
-
nuxt.options.tailwindcss = {
|
|
107
|
-
configPath: resolve('./runtime/assets/config/tailwind.config.cjs')
|
|
108
|
-
}
|
|
68
|
+
if (vuetifyModulePath) {
|
|
69
|
+
await installModule(vuetifyModulePath, options.vuetify || {})
|
|
109
70
|
}
|
|
110
|
-
|
|
111
|
-
//
|
|
112
|
-
// 6. Register plugins (icons, theme, icon switching, search).
|
|
113
|
-
// Only register plugins that require Vuetify when Vuetify is available.
|
|
114
|
-
//
|
|
115
|
-
// Install Vuetify first
|
|
116
|
-
await installModule(resolveModule('vuetify-nuxt-module'), {
|
|
117
|
-
vuetifyOptions: options.vuetify?.vuetifyOptions || {}
|
|
118
|
-
})
|
|
119
|
-
|
|
120
|
-
// THEN load plugins that depend on Vuetify
|
|
121
|
-
addPlugin(resolve('./runtime/plugins/theme'))
|
|
122
|
-
addPlugin(resolve('./runtime/plugins/icon-switcher'))
|
|
123
|
-
|
|
124
|
-
//
|
|
125
|
-
// 7. Auto-import components from this module
|
|
126
|
-
//
|
|
127
|
-
addComponentsDir({
|
|
128
|
-
path: resolve('./runtime/components'),
|
|
129
|
-
pathPrefix: false,
|
|
130
|
-
prefix: 'M'
|
|
131
|
-
})
|
|
132
|
-
|
|
133
|
-
addComponentsDir({
|
|
134
|
-
path: resolve('./runtime/search/components'),
|
|
135
|
-
prefix: 'M'
|
|
136
|
-
})
|
|
137
71
|
}
|
|
138
72
|
})
|