vuetify-nuxt-module 0.4.3 β†’ 0.4.4

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/README.md CHANGED
@@ -1,379 +1,413 @@
1
- <div align="center">
2
- <picture>
3
- <source media="(prefers-color-scheme: dark)" srcset="https://github.com/userquin/vuetify-nuxt-module/raw/main/hero-dark.svg" />
4
- <img alt="vuetify-nuxt-module - Zero-config Nuxt module for Vuetify" src='https://github.com/userquin/vuetify-nuxt-module/raw/main/hero.svg' alt="vuetify-nuxt-module - Zero-config Nuxt module for Vuetify"><br>
5
- </picture>
6
- <p>Zero-config Nuxt module for Vuetify</p>
7
- </div>
8
-
9
- <p align='center'>
10
- <a href='https://www.npmjs.com/package/vuetify-nuxt-module' target="__blank">
11
- <img src='https://img.shields.io/npm/v/vuetify-nuxt-module?color=33A6B8&label=' alt="NPM version">
12
- </a>
13
- <a href="https://www.npmjs.com/package/vuetify-nuxt-module" target="__blank">
14
- <img alt="NPM Downloads" src="https://img.shields.io/npm/dm/vuetify-nuxt-module?color=476582&label=">
15
- </a>
16
- <!--
17
- <a href="https://vite-pwa-org.netlify.app/frameworks/nuxt" target="__blank">
18
- <img src="https://img.shields.io/static/v1?label=&message=docs%20%26%20guides&color=2e859c" alt="Docs & Guides">
19
- </a>
20
- -->
21
- <br>
22
- <a href="https://github.com/userquin/vuetify-nuxt-module" target="__blank">
23
- <img alt="GitHub stars" src="https://img.shields.io/github/stars/userquin/vuetify-nuxt-module?style=social">
24
- </a>
25
- </p>
26
-
27
- <br>
28
-
29
- ## πŸš€ Features
30
-
31
- - πŸ‘Œ **Zero-Config**: sensible built-in default [Vuetify](https://vuetifyjs.com/) configuration for common use cases
32
- - πŸ”© **Extensible**: expose the ability to customize the Vuetify configuration via [Nuxt Plugin Hooks](https://nuxt.com/docs/guide/going-further/hooks#usage-with-plugins)
33
- - ⚑ **Fully Tree Shakable**: by default, only the needed Vuetify components are imported
34
- - πŸ› οΈ **Versatile**: custom Vuetify [directives](https://vuetifyjs.com/en/getting-started/installation/#manual-steps) and [labs components](https://vuetifyjs.com/en/labs/introduction/) registration
35
- - ✨ **Configurable Styles**: configure your variables using [Vuetify SASS Variables](https://vuetifyjs.com/en/features/sass-variables/)
36
- - πŸ’₯ **SSR**: automatic SSR detection and configuration
37
- - πŸ˜ƒ **Icon Fonts**: configure the [icon font](https://vuetifyjs.com/en/features/icon-fonts/) you want to use, the module will automatically import it for you using CDN or local dependencies
38
- - 🎭 **SVG Icons**: ready to use [@mdi/js](https://www.npmjs.com/package/@mdi/js) and [@fortawesome/vue-fontawesome](https://www.npmjs.com/package/@fortawesome/vue-fontawesome) SVG icons packs
39
- - πŸ“¦ **Multiple Icon Sets**: register [multiple icon sets](https://vuetifyjs.com/en/features/icon-fonts/#multiple-icon-sets)
40
- - 🌍 **I18n Ready**: install [@nuxtjs/i18n](https://v8.i18n.nuxtjs.org/) Nuxt module, and you're ready to use Vuetify [internationalization](https://vuetifyjs.com/en/features/internationalization/) features
41
- - πŸ“† **Date Components**: use Vuetify components [that require date functionality](https://vuetifyjs.com/en/features/dates/) installing and configuring one of the [@date-io](https://github.com/dmtrKovalenko/date-io#projects) adapters
42
- - βš™οΈ **Auto-Import Vuetify Composables**: you don't need to import Vuetify composables manually, they are automatically imported for you
43
- - 🎨 **Vuetify Blueprints**: use [Vuetify Blueprints](https://vuetifyjs.com/en/features/blueprints/) to quickly scaffold components
44
- - 🦾 **Type Strong**: written in [TypeScript](https://www.typescriptlang.org/)
45
-
46
- ## πŸ“¦ Install
47
-
48
- > Requires Vite, will not work with Webpack
49
-
50
- ```bash
51
- npm i vuetify-nuxt-module -D
52
-
53
- # yarn
54
- yarn add vuetify-nuxt-module -D
55
-
56
- # pnpm
57
- pnpm add vuetify-nuxt-module -D
58
- ```
59
-
60
- [![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/github/userquin/vuetify-nuxt-module)
61
-
62
- ## πŸ¦„ Usage
63
-
64
- > `vuetify-nuxt-module` is strongly opinionated and has a built-in default configuration out of the box. You can use it without any configuration, and it will work for most use cases.
65
-
66
- Add `vuetify-nuxt-module` module to `nuxt.config.ts` and configure it:
67
-
68
- ```ts
69
- // Nuxt config file
70
- import { defineNuxtConfig } from 'nuxt/config'
71
-
72
- export default defineNuxtConfig({
73
- modules: [
74
- 'vuetify-nuxt-module'
75
- ],
76
- vuetify: {
77
- moduleOptions: {
78
- /* module specific options */
79
- },
80
- vuetifyOptions: {
81
- /* vuetify options */
82
- }
83
- }
84
- })
85
- ```
86
-
87
- ## πŸ”₯ Components, Directives, Lab Components
88
-
89
- The module will enable automatic tree shaking for Vuetify components.
90
-
91
- You don't need to install any Vuetify Vite Plugin (the module will throw an error if any Vuetify Vite Plugin is installed in your Nuxt configuration):
92
- - the module will provide auto-import support via `vuetify/dist/json/importMap.json` json file and Nuxt `components:extend` hook.
93
- - the module will register a custom Vite Plugin for Vuetify styles: it is just a copy from the original Vuetify Vite Styles Plugin, changing some virtual names mappings and handling SSR flags.
94
-
95
- ### Global Components
96
-
97
- If you need to add some global component, use `vuetifyOptions.components` module option, it has been declared properly to have better DX.
98
-
99
- Check the [components definition](https://github.com/userquin/vuetify-nuxt-module/blob/main/src/types.ts#L80-L81).
100
-
101
- You can also provide [Aliasing & Virtual Components](https://vuetifyjs.com/en/features/aliasing/#virtual-component-defaults) via `vuetifyOptions.aliases` module option to register components with a different name, only available for global components. The components require to be registered globally.
102
-
103
- ### Directives
104
-
105
- By default, the module will not register any Vuetify directive. If you need to register some directive, use `vuetifyOptions.directives` module option, it has been declared properly to have better DX.
106
-
107
- You can register all the directives or only the ones you need: check the [directives definition](https://github.com/userquin/vuetify-nuxt-module/blob/main/src/types.ts#L82-L83).
108
-
109
- ### Labs Components
110
-
111
- The module provides support to use Vuetify [labs components](https://vuetifyjs.com/en/labs/introduction/) via `vuetifyOptions.labsComponents` module option, it has been declared properly to have better DX.
112
-
113
- You can register all the labs components or only the ones you need: check the [labsComponent definition](https://github.com/userquin/vuetify-nuxt-module/blob/main/src/types.ts#L84-L85).
114
-
115
- ## πŸ˜ƒ Font Icons
116
-
117
- This module supports the following font icons libraries:
118
- - [Material Design Icons](https://materialdesignicons.com/)
119
- - [Material Icons](https://fonts.google.com/icons)
120
- - [Font Awesome 4](https://fontawesome.com/v4.7.0/)
121
- - [Font Awesome 5](https://fontawesome.com/)
122
-
123
- By default, the module will use the `mdi` font icon library. You can change it by setting the `defaultSet` option to:
124
- - `mdi` for [Material Design Icons](https://materialdesignicons.com/)
125
- - `md` for [Material Icons](https://fonts.google.com/icons)
126
- - `fa4` for [Font Awesome 4](https://fontawesome.com/v4.7.0/)
127
- - `fa` for [Font Awesome 5](https://fontawesome.com)
128
-
129
- To configure a font icon you only need to specify the default set:
130
- ```ts
131
- // Nuxt config file
132
- import { defineNuxtConfig } from 'nuxt/config'
133
-
134
- export default defineNuxtConfig({
135
- modules: [
136
- 'vuetify-nuxt-module'
137
- ],
138
- vuetify: {
139
- vuetifyOptions: {
140
- icons: {
141
- defaultSet: 'mdi'
142
- }
143
- }
144
- }
145
- })
146
- ```
147
-
148
- The module will use the CDN version of the font icon. If you want to use the local version, you only need to install the corresponding dependency, the module will auto-detect it and will switch to register the font to use the local version.
149
-
150
- The CDN used for each font icon library, you can use the `cdn` option to change it:
151
- - [CDN for Material Design Icons (mdi)](https://cdn.jsdelivr.net/npm/@mdi/font@5.x/css/materialdesignicons.min.css)
152
- - [CDN for Material Icons (md)](https://fonts.googleapis.com/css?family=Material+Icons)
153
- - [CDN for Font Awesome 4 (fa4)](https://cdn.jsdelivr.net/npm/font-awesome@4.x/css/font-awesome.min.css)
154
- - [CDN for Font Awesome 5 (fa)](https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@latest/css/all.min.css)
155
-
156
- To change the CDN for a font icon library you only need to specify the `cdn` option:
157
- ```ts
158
- // Nuxt config file
159
- import { defineNuxtConfig } from 'nuxt/config'
160
-
161
- export default defineNuxtConfig({
162
- modules: [
163
- 'vuetify-nuxt-module'
164
- ],
165
- vuetify: {
166
- vuetifyOptions: {
167
- icons: {
168
- defaultSet: 'mdi',
169
- sets: [{
170
- name: 'mdi',
171
- cdn: 'https://cdn.jsdelivr.net/npm/@mdi/font@latest/css/materialdesignicons'
172
- }]
173
- }
174
- }
175
- }
176
- })
177
- ```
178
-
179
- ## 🎭 SVG Icons
180
-
181
- This module supports the following SVG icon libraries:
182
- - [@mdi/js](https://www.npmjs.com/package/@mdi/js)
183
- - [@fortawesome/fontawesome-svg-core](https://www.npmjs.com/package/@fortawesome/fontawesome-svg-core)
184
-
185
- We're trying to figure out how to include the following SVG icon libraries:
186
- - [Nuxt Icon](https://github.com/nuxt-modules/icon)
187
- - [unplugin-icons](https://github.com/antfu/unplugin-icons)
188
-
189
- ### mdi-svg
190
-
191
- You only need to add `@mdi/js` dependency to your project and configure the default set:
192
- ```ts
193
- // Nuxt config file
194
- import { defineNuxtConfig } from 'nuxt/config'
195
-
196
- export default defineNuxtConfig({
197
- modules: [
198
- 'vuetify-nuxt-module'
199
- ],
200
- vuetify: {
201
- vuetifyOptions: {
202
- icons: {
203
- defaultSet: 'mdi-svg'
204
- }
205
- }
206
- }
207
- })
208
- ```
209
-
210
- You can also add icon aliases:
211
- ```ts
212
- // Nuxt config file
213
- import { defineNuxtConfig } from 'nuxt/config'
214
-
215
- export default defineNuxtConfig({
216
- modules: [
217
- 'vuetify-nuxt-module'
218
- ],
219
- vuetify: {
220
- vuetifyOptions: {
221
- icons: {
222
- defaultSet: 'mdi-svg',
223
- svg: {
224
- mdi: {
225
- aliases: {
226
- account: 'mdiAccount'
227
- }
228
- }
229
- }
230
- }
231
- }
232
- }
233
- })
234
- ```
235
-
236
- ### fa-svg
237
-
238
- You only need to add `@fortawesome/fontawesome-svg-core`, `@fortawesome/vue-fontawesome` and `@fortawesome/free-solid-svg-icons` dependencies to your project and configure the default set:
239
- ```ts
240
- // Nuxt config file
241
- import { defineNuxtConfig } from 'nuxt/config'
242
-
243
- export default defineNuxtConfig({
244
- modules: [
245
- 'vuetify-nuxt-module'
246
- ],
247
- vuetify: {
248
- vuetifyOptions: {
249
- icons: {
250
- defaultSet: 'fa-svg'
251
- }
252
- }
253
- }
254
- })
255
- ```
256
-
257
- You can also add more libraries and install them in your project, the module will register them for you (this is the default configuration using the above configuration):
258
- ```ts
259
- // Nuxt config file
260
- import { defineNuxtConfig } from 'nuxt/config'
261
-
262
- export default defineNuxtConfig({
263
- modules: [
264
- 'vuetify-nuxt-module'
265
- ],
266
- vuetify: {
267
- vuetifyOptions: {
268
- icons: {
269
- defaultSet: 'fa-svg',
270
- svg: {
271
- fa: {
272
- libraries: [
273
- [/* default export? */ false, /* export name */ 'fas', /* library */ '@fortawesome/free-solid-svg-icons']
274
- ]
275
- }
276
- }
277
- }
278
- }
279
- }
280
- })
281
- ```
282
-
283
- ## πŸ“¦ Multiple Icon Sets
284
-
285
- You can register multiple icons sets adding them to the sets array, don't forget to add the default set, otherwise 'mdi' will be used:
286
- ```ts
287
- // Nuxt config file
288
- import { defineNuxtConfig } from 'nuxt/config'
289
-
290
- export default defineNuxtConfig({
291
- modules: [
292
- 'vuetify-nuxt-module'
293
- ],
294
- vuetify: {
295
- vuetifyOptions: {
296
- icons: {
297
- defaultSet: 'mdi',
298
- sets: ['mdi', 'fa']
299
- }
300
- }
301
- }
302
- })
303
- ```
304
-
305
- ## 🌍 I18n support
306
-
307
- > Requires latest [@nuxtjs/i18n](https://v8.i18n.nuxtjs.org/) Nuxt module: `8.0.0.beta.13`.
308
-
309
- You can check the playground folder, you can run it using single or multiple json files per locale:
310
- - for single file per locale: run from root folder `pnpm install && nr dev:prepare && nr dev`
311
- - for multiple files per locale: run from root folder `pnpm install && nr dev:prepare:multiple-json && nr dev:multiple-json`
312
-
313
- ## πŸ“† Date components support
314
-
315
- Right now you can only use Vuetify adapter, there is a bug and will not work, I'm working on it: https://github.com/userquin/vuetify-nuxt-module/pull/9#issuecomment-1620023814.
316
-
317
- To use Vuetify components [that require date functionality](https://vuetifyjs.com/en/features/dates/):
318
- - install one of the [@date-io](https://github.com/dmtrKovalenko/date-io#projects) adapters (optional)
319
- - configure the date entry in your Vuetify configuration:
320
- ```ts
321
- vuetifyOptions: {
322
- date: {
323
- adapter: 'vuetify' // 'vuetify' | 'date-fns' | 'moment' | 'luxon' | 'dayjs' | 'js-joda' | 'date-fns-jalali' | 'jalaali' | 'hijri' | 'custom'
324
- }
325
- }
326
- ```
327
-
328
- If you also have `@nuxtjs/i18n` module installed, `vuetifyOptions.date.locale` will be automatically configured, beware, the configured `locale` entry will be ignored.
329
-
330
- If you want to use a custom date adapter, you can configure it using `vuetifyOptions.date.adapter = 'custom'`, and then:
331
- - add a Nuxt Plugin and add the `vuetify:configuration` hook to configure your Vuetify options
332
- - you can import the `virtual:vuetify-date-configuration` module, you will have access to the configuration:
333
- ```ts
334
- import { adapter, dateConfiguration, i18n } from 'virtual:vuetify-date-configuration'
335
- ```
336
-
337
- Check out [vuetify-date](https://github.com/userquin/vuetify-nuxt-module/blob/main/src/runtime/plugins/vuetify-date.mts) plugin for an example of a custom date adapter and how to access to the configuration.
338
-
339
- ## βš™οΈ Auto-Import Vuetify Composables
340
-
341
- No more Vuetify composables manual imports, auto import is enabled by default:
342
- - [useDate](https://vuetifyjs.com/en/api/use-date/)
343
- - [useDefaults](https://vuetifyjs.com/en/api/use-defaults/)
344
- - [useDisplay](https://vuetifyjs.com/en/api/use-display/)
345
- - [useLayout](https://vuetifyjs.com/en/api/use-layout/)
346
- - [useLocale](https://vuetifyjs.com/en/api/use-locale/)
347
- - [useRtl](https://vuetifyjs.com/en/api/use-rtl/)
348
- - [useTheme](https://vuetifyjs.com/en/api/use-theme/)
349
-
350
- You can disable auto-import using `moduleOptions.importComposables: false`.
351
-
352
- If you are using another composables that collide with the Vuetify ones, enable `moduleOptions.prefixComposables: true` to prefix them with `V`:
353
- - `useLocale` => `useVLocale`
354
- - `useDefaults` => `useVDefaults`
355
- - `useDisplay` => `useVDisplay`
356
- - `useLayout` => `useVLayout`
357
- - `useRtl` => `useVRtl`
358
- - `useTheme` => `useVTheme`
359
-
360
-
361
- ## 🎨 Vuetify Blueprints
362
-
363
- The module supports Vuetify Blueprints, just add it to the `vuetifyOptions.blueprint` module option, but with some limitations:
364
- - `ssr` will be ignored, this flag can be only configured internally by the module via the Nuxt ssr option.
365
- - `components` will be ignored, configure them using the `vuetifyOptions.components` module option
366
- - `directives` will be ignored, configure them using the `vuetifyOptions.directives` module option.
367
- - `locale` will be ignored, configure it using the `vuetifyOptions.locale` module option.
368
- - `date` will be ignored, configure it using the `vuetifyOptions.date` module option.
369
- - `icons` will be ignored, configure it using the `vuetifyOptions.icons` module option.
370
-
371
- ## πŸ‘€ Full config
372
-
373
- Check out the type declaration [src/types.ts](https://github.com/userquin/vuetify-nuxt-module/blob/main/src/types.ts).
374
-
375
- The virtual modules can be found in [configuration.d.ts](https://github.com/userquin/vuetify-nuxt-module/blob/main/configuration.d.ts) file.
376
-
377
- ## πŸ“„ License
378
-
379
- [MIT](https://github.com/userquin/vuetify-nuxt-module/blob/main/LICENSE) License &copy; 2023-PRESENT [JoaquΓ­n SΓ‘nchez](https://github.com/userquin)
1
+ <div align="center">
2
+ <picture>
3
+ <source media="(prefers-color-scheme: dark)" srcset="https://github.com/userquin/vuetify-nuxt-module/raw/main/hero-dark.svg" />
4
+ <img alt="vuetify-nuxt-module - Zero-config Nuxt module for Vuetify" src='https://github.com/userquin/vuetify-nuxt-module/raw/main/hero.svg' alt="vuetify-nuxt-module - Zero-config Nuxt module for Vuetify"><br>
5
+ </picture>
6
+ <p>Zero-config Nuxt module for Vuetify</p>
7
+ </div>
8
+
9
+ <p align='center'>
10
+ <a href='https://www.npmjs.com/package/vuetify-nuxt-module' target="__blank">
11
+ <img src='https://img.shields.io/npm/v/vuetify-nuxt-module?color=33A6B8&label=' alt="NPM version">
12
+ </a>
13
+ <a href="https://www.npmjs.com/package/vuetify-nuxt-module" target="__blank">
14
+ <img alt="NPM Downloads" src="https://img.shields.io/npm/dm/vuetify-nuxt-module?color=476582&label=">
15
+ </a>
16
+ <!--
17
+ <a href="https://vite-pwa-org.netlify.app/frameworks/nuxt" target="__blank">
18
+ <img src="https://img.shields.io/static/v1?label=&message=docs%20%26%20guides&color=2e859c" alt="Docs & Guides">
19
+ </a>
20
+ -->
21
+ <br>
22
+ <a href="https://github.com/userquin/vuetify-nuxt-module" target="__blank">
23
+ <img alt="GitHub stars" src="https://img.shields.io/github/stars/userquin/vuetify-nuxt-module?style=social">
24
+ </a>
25
+ </p>
26
+
27
+ <br>
28
+
29
+ ## πŸš€ Features
30
+
31
+ - πŸ‘Œ **Zero-Config**: sensible built-in default [Vuetify](https://vuetifyjs.com/) configuration for common use cases
32
+ - πŸ”Œ **Extensible**: expose the ability to customize the Vuetify configuration via [Nuxt Plugin Hooks](https://nuxt.com/docs/guide/going-further/hooks#usage-with-plugins)
33
+ - ⚑ **Fully Tree Shakable**: by default, only the needed Vuetify components are imported
34
+ - πŸ› οΈ **Versatile**: custom Vuetify [directives](https://vuetifyjs.com/en/getting-started/installation/#manual-steps) and [labs components](https://vuetifyjs.com/en/labs/introduction/) registration
35
+ - ✨ **Configurable Styles**: configure your variables using [Vuetify SASS Variables](https://vuetifyjs.com/en/features/sass-variables/)
36
+ - πŸ’₯ **SSR**: automatic SSR detection and configuration
37
+ - πŸ˜ƒ **Icon Fonts**: configure the [icon font](https://vuetifyjs.com/en/features/icon-fonts/) you want to use, the module will automatically import it for you using CDN or local dependencies
38
+ - 🎭 **SVG Icons**: ready to use [@mdi/js](https://www.npmjs.com/package/@mdi/js) and [@fortawesome/vue-fontawesome](https://www.npmjs.com/package/@fortawesome/vue-fontawesome) SVG icons packs
39
+ - πŸ“¦ **Multiple Icon Sets**: register [multiple icon sets](https://vuetifyjs.com/en/features/icon-fonts/#multiple-icon-sets)
40
+ - 🌍 **I18n Ready**: install [@nuxtjs/i18n](https://v8.i18n.nuxtjs.org/) Nuxt module, and you're ready to use Vuetify [internationalization](https://vuetifyjs.com/en/features/internationalization/) features
41
+ - πŸ“† **Date Components**: use Vuetify components [that require date functionality](https://vuetifyjs.com/en/features/dates/) installing and configuring one of the [@date-io](https://github.com/dmtrKovalenko/date-io#projects) adapters
42
+ - βš™οΈ **Auto-Import Vuetify Composables**: you don't need to import Vuetify composables manually, they are automatically imported for you
43
+ - 🎨 **Vuetify Blueprints**: use [Vuetify Blueprints](https://vuetifyjs.com/en/features/blueprints/) to quickly scaffold components
44
+ - πŸ”© **Nuxt Layers and Hooks**: load your Vuetify configuration using [Nuxt Layers](https://nuxt.com/docs/getting-started/layers#layers) or using a custom module via `vuetify:registerModule` [Nuxt Hook](https://nuxt.com/docs/guide/going-further/hooks#nuxt-hooks-build-time)
45
+ - πŸ‘€ **Nuxt DevTools**: ready to inspect your Vuetify styles with the [Nuxt DevTools](https://github.com/nuxt/devtools) inspector
46
+ - 🦾 **Type Strong**: written in [TypeScript](https://www.typescriptlang.org/)
47
+
48
+ ## πŸ“¦ Install
49
+
50
+ > Requires Vite, will not work with Webpack
51
+
52
+ ```bash
53
+ npm i vuetify-nuxt-module -D
54
+
55
+ # yarn
56
+ yarn add vuetify-nuxt-module -D
57
+
58
+ # pnpm
59
+ pnpm add vuetify-nuxt-module -D
60
+ ```
61
+
62
+ [![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/github/userquin/vuetify-nuxt-module)
63
+
64
+ ## πŸ¦„ Usage
65
+
66
+ > `vuetify-nuxt-module` is strongly opinionated and has a built-in default configuration out of the box. You can use it without any configuration, and it will work for most use cases.
67
+
68
+ Add `vuetify-nuxt-module` module to `nuxt.config.ts` and configure it:
69
+
70
+ ```ts
71
+ // Nuxt config file
72
+ import { defineNuxtConfig } from 'nuxt/config'
73
+
74
+ export default defineNuxtConfig({
75
+ modules: [
76
+ 'vuetify-nuxt-module'
77
+ ],
78
+ vuetify: {
79
+ moduleOptions: {
80
+ /* module specific options */
81
+ },
82
+ vuetifyOptions: {
83
+ /* vuetify options */
84
+ }
85
+ }
86
+ })
87
+ ```
88
+
89
+ ## πŸ”₯ Components, Directives, Lab Components
90
+
91
+ The module will enable automatic tree shaking for Vuetify components.
92
+
93
+ You don't need to install any Vuetify Vite Plugin (the module will throw an error if any Vuetify Vite Plugin is installed in your Nuxt configuration):
94
+ - the module will provide auto-import support via `vuetify/dist/json/importMap.json` json file and Nuxt `components:extend` hook.
95
+ - the module will register a custom Vite Plugin for Vuetify styles: it is just a copy from the original Vuetify Vite Styles Plugin, changing some virtual names mappings and handling SSR flags.
96
+
97
+ ### Global Components
98
+
99
+ If you need to add some global component, use `vuetifyOptions.components` module option, it has been declared properly to have better DX.
100
+
101
+ Check the [components definition](https://github.com/userquin/vuetify-nuxt-module/blob/main/src/types.ts#L80-L81).
102
+
103
+ You can also provide [Aliasing & Virtual Components](https://vuetifyjs.com/en/features/aliasing/#virtual-component-defaults) via `vuetifyOptions.aliases` module option to register components with a different name, only available for global components. The components require to be registered globally.
104
+
105
+ ### Directives
106
+
107
+ By default, the module will not register any Vuetify directive. If you need to register some directive, use `vuetifyOptions.directives` module option, it has been declared properly to have better DX.
108
+
109
+ You can register all the directives or only the ones you need: check the [directives definition](https://github.com/userquin/vuetify-nuxt-module/blob/main/src/types.ts#L82-L83).
110
+
111
+ ### Labs Components
112
+
113
+ The module provides support to use Vuetify [labs components](https://vuetifyjs.com/en/labs/introduction/) via `vuetifyOptions.labsComponents` module option, it has been declared properly to have better DX.
114
+
115
+ You can register all the labs components or only the ones you need: check the [labsComponent definition](https://github.com/userquin/vuetify-nuxt-module/blob/main/src/types.ts#L84-L85).
116
+
117
+ ## πŸ”© Nuxt Layers and Hooks
118
+
119
+ You can load your Vuetify configuration using [Nuxt Layers](https://nuxt.com/docs/getting-started/layers#layers) or using a custom module via `vuetify:registerModule` [Nuxt Hook](https://nuxt.com/docs/guide/going-further/hooks#nuxt-hooks-build-time).
120
+
121
+ ### Nuxt Layers
122
+
123
+ Add your Vuetify configuration to a layer and then configure the module to use it:
124
+ ```ts
125
+ // Nuxt config file
126
+ import { defineNuxtConfig } from 'nuxt/config'
127
+
128
+ export default defineNuxtConfig({
129
+ extends: ['my-awesome-vuetify-layer'],
130
+ modules: ['vuetify-nuxt-module']
131
+ })
132
+ ```
133
+
134
+ ### Nuxt Hook
135
+
136
+ You can use a custom module to load your Vuetify configuration:
137
+ ```ts
138
+ // Nuxt config file
139
+ import MyVuetifyModule from './modules/my-vuetify-module'
140
+
141
+ export default defineNuxtConfig({
142
+ modules: [MyVuetifyModule, 'vuetify-nuxt-module']
143
+ })
144
+ ```
145
+
146
+ and your module will load your configuration via `vuetify:registerModule` Nuxt hook:
147
+ ```ts
148
+ // modules/my-vuetify-module
149
+ export default defineNuxtModule({
150
+ setup(_options, nuxt) {
151
+ nuxt.hook('vuetify:registerModule', register => register({
152
+ moduleOptions: {
153
+ /* module specific options */
154
+ },
155
+ vuetifyOptions: {
156
+ /* vuetify options */
157
+ },
158
+ }))
159
+ },
160
+ })
161
+ ```
162
+
163
+ ## πŸ˜ƒ Font Icons
164
+
165
+ This module supports the following font icons libraries:
166
+ - [Material Design Icons](https://materialdesignicons.com/)
167
+ - [Material Icons](https://fonts.google.com/icons)
168
+ - [Font Awesome 4](https://fontawesome.com/v4.7.0/)
169
+ - [Font Awesome 5](https://fontawesome.com/)
170
+
171
+ By default, the module will use the `mdi` font icon library. You can change it by setting the `defaultSet` option to:
172
+ - `mdi` for [Material Design Icons](https://materialdesignicons.com/)
173
+ - `md` for [Material Icons](https://fonts.google.com/icons)
174
+ - `fa4` for [Font Awesome 4](https://fontawesome.com/v4.7.0/)
175
+ - `fa` for [Font Awesome 5](https://fontawesome.com)
176
+
177
+ To configure a font icon you only need to specify the default set:
178
+ ```ts
179
+ // Nuxt config file
180
+ import { defineNuxtConfig } from 'nuxt/config'
181
+
182
+ export default defineNuxtConfig({
183
+ modules: ['vuetify-nuxt-module'],
184
+ vuetify: {
185
+ vuetifyOptions: {
186
+ icons: {
187
+ defaultSet: 'mdi'
188
+ }
189
+ }
190
+ }
191
+ })
192
+ ```
193
+
194
+ The module will use the CDN version of the font icon. If you want to use the local version, you only need to install the corresponding dependency, the module will auto-detect it and will switch to register the font to use the local version.
195
+
196
+ The CDN used for each font icon library, you can use the `cdn` option to change it:
197
+ - [CDN for Material Design Icons (mdi)](https://cdn.jsdelivr.net/npm/@mdi/font@5.x/css/materialdesignicons.min.css)
198
+ - [CDN for Material Icons (md)](https://fonts.googleapis.com/css?family=Material+Icons)
199
+ - [CDN for Font Awesome 4 (fa4)](https://cdn.jsdelivr.net/npm/font-awesome@4.x/css/font-awesome.min.css)
200
+ - [CDN for Font Awesome 5 (fa)](https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@latest/css/all.min.css)
201
+
202
+ To change the CDN for a font icon library you only need to specify the `cdn` option:
203
+ ```ts
204
+ // Nuxt config file
205
+ import { defineNuxtConfig } from 'nuxt/config'
206
+
207
+ export default defineNuxtConfig({
208
+ modules: ['vuetify-nuxt-module'],
209
+ vuetify: {
210
+ vuetifyOptions: {
211
+ icons: {
212
+ defaultSet: 'mdi',
213
+ sets: [{
214
+ name: 'mdi',
215
+ cdn: 'https://cdn.jsdelivr.net/npm/@mdi/font@latest/css/materialdesignicons'
216
+ }]
217
+ }
218
+ }
219
+ }
220
+ })
221
+ ```
222
+
223
+ ## 🎭 SVG Icons
224
+
225
+ This module supports the following SVG icon libraries:
226
+ - [@mdi/js](https://www.npmjs.com/package/@mdi/js)
227
+ - [@fortawesome/fontawesome-svg-core](https://www.npmjs.com/package/@fortawesome/fontawesome-svg-core)
228
+
229
+ We're trying to figure out how to include the following SVG icon libraries:
230
+ - [Nuxt Icon](https://github.com/nuxt-modules/icon)
231
+ - [unplugin-icons](https://github.com/antfu/unplugin-icons)
232
+
233
+ ### mdi-svg
234
+
235
+ You only need to add `@mdi/js` dependency to your project and configure the default set:
236
+ ```ts
237
+ // Nuxt config file
238
+ import { defineNuxtConfig } from 'nuxt/config'
239
+
240
+ export default defineNuxtConfig({
241
+ modules: ['vuetify-nuxt-module'],
242
+ vuetify: {
243
+ vuetifyOptions: {
244
+ icons: {
245
+ defaultSet: 'mdi-svg'
246
+ }
247
+ }
248
+ }
249
+ })
250
+ ```
251
+
252
+ You can also add icon aliases:
253
+ ```ts
254
+ // Nuxt config file
255
+ import { defineNuxtConfig } from 'nuxt/config'
256
+
257
+ export default defineNuxtConfig({
258
+ modules: ['vuetify-nuxt-module'],
259
+ vuetify: {
260
+ vuetifyOptions: {
261
+ icons: {
262
+ defaultSet: 'mdi-svg',
263
+ svg: {
264
+ mdi: {
265
+ aliases: {
266
+ account: 'mdiAccount'
267
+ }
268
+ }
269
+ }
270
+ }
271
+ }
272
+ }
273
+ })
274
+ ```
275
+
276
+ ### fa-svg
277
+
278
+ You only need to add `@fortawesome/fontawesome-svg-core`, `@fortawesome/vue-fontawesome` and `@fortawesome/free-solid-svg-icons` dependencies to your project and configure the default set:
279
+ ```ts
280
+ // Nuxt config file
281
+ import { defineNuxtConfig } from 'nuxt/config'
282
+
283
+ export default defineNuxtConfig({
284
+ modules: ['vuetify-nuxt-module'],
285
+ vuetify: {
286
+ vuetifyOptions: {
287
+ icons: {
288
+ defaultSet: 'fa-svg'
289
+ }
290
+ }
291
+ }
292
+ })
293
+ ```
294
+
295
+ You can also add more libraries and install them in your project, the module will register them for you (this is the default configuration using the above configuration):
296
+ ```ts
297
+ // Nuxt config file
298
+ import { defineNuxtConfig } from 'nuxt/config'
299
+
300
+ export default defineNuxtConfig({
301
+ modules: ['vuetify-nuxt-module'],
302
+ vuetify: {
303
+ vuetifyOptions: {
304
+ icons: {
305
+ defaultSet: 'fa-svg',
306
+ svg: {
307
+ fa: {
308
+ libraries: [
309
+ [/* default export? */ false, /* export name */ 'fas', /* library */ '@fortawesome/free-solid-svg-icons']
310
+ ]
311
+ }
312
+ }
313
+ }
314
+ }
315
+ }
316
+ })
317
+ ```
318
+
319
+ ## πŸ“¦ Multiple Icon Sets
320
+
321
+ You can register multiple icons sets adding them to the sets array, don't forget to add the default set, otherwise 'mdi' will be used:
322
+ ```ts
323
+ // Nuxt config file
324
+ import { defineNuxtConfig } from 'nuxt/config'
325
+
326
+ export default defineNuxtConfig({
327
+ modules: ['vuetify-nuxt-module'],
328
+ vuetify: {
329
+ vuetifyOptions: {
330
+ icons: {
331
+ defaultSet: 'mdi',
332
+ sets: ['mdi', 'fa']
333
+ }
334
+ }
335
+ }
336
+ })
337
+ ```
338
+
339
+ ## 🌍 I18n support
340
+
341
+ > Requires latest [@nuxtjs/i18n](https://v8.i18n.nuxtjs.org/) Nuxt module: `8.0.0.beta.13`.
342
+
343
+ You can check the playground folder, you can run it using single or multiple json files per locale:
344
+ - for single file per locale: run from root folder `pnpm install && nr dev:prepare && nr dev`
345
+ - for multiple files per locale: run from root folder `pnpm install && nr dev:prepare:multiple-json && nr dev:multiple-json`
346
+
347
+ ## πŸ“† Date components support
348
+
349
+ Right now you can only use Vuetify adapter, there is a bug and will not work, I'm working on it: https://github.com/userquin/vuetify-nuxt-module/pull/9#issuecomment-1620023814.
350
+
351
+ To use Vuetify components [that require date functionality](https://vuetifyjs.com/en/features/dates/):
352
+ - install one of the [@date-io](https://github.com/dmtrKovalenko/date-io#projects) adapters (optional)
353
+ - configure the date entry in your Vuetify configuration:
354
+ ```ts
355
+ vuetifyOptions: {
356
+ date: {
357
+ adapter: 'vuetify' // 'vuetify' | 'date-fns' | 'moment' | 'luxon' | 'dayjs' | 'js-joda' | 'date-fns-jalali' | 'jalaali' | 'hijri' | 'custom'
358
+ }
359
+ }
360
+ ```
361
+
362
+ If you also have `@nuxtjs/i18n` module installed, `vuetifyOptions.date.locale` will be automatically configured, beware, the configured `locale` entry will be ignored.
363
+
364
+ If you want to use a custom date adapter, you can configure it using `vuetifyOptions.date.adapter = 'custom'`, and then:
365
+ - add a Nuxt Plugin and add the `vuetify:configuration` hook to configure your Vuetify options
366
+ - you can import the `virtual:vuetify-date-configuration` module, you will have access to the configuration:
367
+ ```ts
368
+ import { adapter, dateConfiguration, i18n } from 'virtual:vuetify-date-configuration'
369
+ ```
370
+
371
+ Check out [vuetify-date](https://github.com/userquin/vuetify-nuxt-module/blob/main/src/runtime/plugins/vuetify-date.mts) plugin for an example of a custom date adapter and how to access to the configuration.
372
+
373
+ ## βš™οΈ Auto-Import Vuetify Composables
374
+
375
+ No more Vuetify composables manual imports, auto import is enabled by default:
376
+ - [useDate](https://vuetifyjs.com/en/api/use-date/)
377
+ - [useDefaults](https://vuetifyjs.com/en/api/use-defaults/)
378
+ - [useDisplay](https://vuetifyjs.com/en/api/use-display/)
379
+ - [useLayout](https://vuetifyjs.com/en/api/use-layout/)
380
+ - [useLocale](https://vuetifyjs.com/en/api/use-locale/)
381
+ - [useRtl](https://vuetifyjs.com/en/api/use-rtl/)
382
+ - [useTheme](https://vuetifyjs.com/en/api/use-theme/)
383
+
384
+ You can disable auto-import using `moduleOptions.importComposables: false`.
385
+
386
+ If you are using another composables that collide with the Vuetify ones, enable `moduleOptions.prefixComposables: true` to prefix them with `V`:
387
+ - `useLocale` => `useVLocale`
388
+ - `useDefaults` => `useVDefaults`
389
+ - `useDisplay` => `useVDisplay`
390
+ - `useLayout` => `useVLayout`
391
+ - `useRtl` => `useVRtl`
392
+ - `useTheme` => `useVTheme`
393
+
394
+
395
+ ## 🎨 Vuetify Blueprints
396
+
397
+ The module supports Vuetify Blueprints, just add it to the `vuetifyOptions.blueprint` module option, but with some limitations:
398
+ - `ssr` will be ignored, this flag can be only configured internally by the module via the Nuxt ssr option
399
+ - `components` will be ignored, configure them using the `vuetifyOptions.components` module option
400
+ - `directives` will be ignored, configure them using the `vuetifyOptions.directives` module option
401
+ - `locale` will be ignored, configure it using the `vuetifyOptions.locale` module option
402
+ - `date` will be ignored, configure it using the `vuetifyOptions.date` module option
403
+ - `icons` will be ignored, configure it using the `vuetifyOptions.icons` module option
404
+
405
+ ## πŸ‘€ Full config
406
+
407
+ Check out the type declaration [src/types.ts](https://github.com/userquin/vuetify-nuxt-module/blob/main/src/types.ts).
408
+
409
+ The virtual modules can be found in [configuration.d.ts](https://github.com/userquin/vuetify-nuxt-module/blob/main/configuration.d.ts) file.
410
+
411
+ ## πŸ“„ License
412
+
413
+ [MIT](https://github.com/userquin/vuetify-nuxt-module/blob/main/LICENSE) License &copy; 2023-PRESENT [JoaquΓ­n SΓ‘nchez](https://github.com/userquin)
package/dist/module.d.ts CHANGED
@@ -174,6 +174,14 @@ interface ModuleOptions {
174
174
  */
175
175
  vuetifyOptions?: VOptions;
176
176
  }
177
+ declare module '@nuxt/schema' {
178
+ interface NuxtConfig {
179
+ vuetify?: ModuleOptions;
180
+ }
181
+ interface NuxtHooks {
182
+ 'vuetify:registerModule': (registerModule: (config: ModuleOptions) => void) => void;
183
+ }
184
+ }
177
185
  declare module '#app' {
178
186
  interface NuxtApp {
179
187
  $vuetify: ReturnType<typeof vuetify['createVuetify']>;
package/dist/module.json CHANGED
@@ -4,5 +4,5 @@
4
4
  "compatibility": {
5
5
  "nuxt": "^3.0.0"
6
6
  },
7
- "version": "0.4.3"
7
+ "version": "0.4.4"
8
8
  }
package/dist/module.mjs CHANGED
@@ -1,12 +1,12 @@
1
1
  import { utimes, readFile } from 'node:fs/promises';
2
- import { useLogger, defineNuxtModule, createResolver, hasNuxtModule, extendWebpackConfig, addImports, addPlugin } from '@nuxt/kit';
2
+ import { useLogger, defineNuxtModule, isNuxt3, getNuxtVersion, createResolver, hasNuxtModule, extendWebpackConfig, addImports, addPlugin } from '@nuxt/kit';
3
3
  import defu from 'defu';
4
- import { isPackageExists } from 'local-pkg';
5
4
  import { resolveVuetifyBase, normalizePath, writeStyles, cacheDir } from '@vuetify/loader-shared';
6
5
  import { isAbsolute, join, relative } from 'pathe';
7
6
  import { normalizePath as normalizePath$1 } from 'vite';
7
+ import { isPackageExists } from 'local-pkg';
8
8
 
9
- const version = "0.4.3";
9
+ const version = "0.4.4";
10
10
 
11
11
  function isSubdir(root, test) {
12
12
  const relative$1 = relative(root, test);
@@ -545,6 +545,41 @@ function toKebabCase(str = "") {
545
545
  }
546
546
  toKebabCase.cache = /* @__PURE__ */ new Map();
547
547
 
548
+ function detectDate() {
549
+ const result = [];
550
+ return result;
551
+ }
552
+ function cleanupBlueprint(vuetifyOptions) {
553
+ const blueprint = vuetifyOptions.blueprint;
554
+ if (blueprint) {
555
+ delete blueprint.ssr;
556
+ delete blueprint.components;
557
+ delete blueprint.directives;
558
+ delete blueprint.locale;
559
+ delete blueprint.date;
560
+ delete blueprint.icons;
561
+ vuetifyOptions.blueprint = blueprint;
562
+ }
563
+ }
564
+
565
+ async function mergeVuetifyModules(options, nuxt) {
566
+ const moduleOptions = [];
567
+ await nuxt.callHook("vuetify:registerModule", (layerModuleOptions) => moduleOptions.push(layerModuleOptions));
568
+ if (nuxt.options._layers.length > 1) {
569
+ nuxt.options._layers.forEach((layer, idx) => {
570
+ if (idx > 0 && layer.config.vuetify)
571
+ moduleOptions.push(layer.config.vuetify);
572
+ });
573
+ }
574
+ moduleOptions.push(options);
575
+ if (moduleOptions.length > 1) {
576
+ const [base, ...rest] = moduleOptions;
577
+ return defu(base, ...rest);
578
+ } else {
579
+ return options;
580
+ }
581
+ }
582
+
548
583
  const CONFIG_KEY = "vuetify";
549
584
  const logger = useLogger(`nuxt:${CONFIG_KEY}`);
550
585
  const module = defineNuxtModule({
@@ -565,9 +600,12 @@ const module = defineNuxtModule({
565
600
  styles: true
566
601
  }
567
602
  }),
568
- setup(options, nuxt) {
603
+ async setup(options, nuxt) {
569
604
  var _a, _b;
605
+ if (!isNuxt3(nuxt))
606
+ logger.error(`Cannot support nuxt version: ${getNuxtVersion(nuxt)}`);
570
607
  const resolver = createResolver(import.meta.url);
608
+ options = await mergeVuetifyModules(options, nuxt);
571
609
  const { vuetifyOptions = {} } = options;
572
610
  const {
573
611
  directives = false,
@@ -721,21 +759,5 @@ function checkVuetifyPlugins(config) {
721
759
  if (plugin)
722
760
  throw new Error("Remove vite-plugin-vuetify plugin from Vite Plugins entry in Nuxt config file!");
723
761
  }
724
- function detectDate() {
725
- const result = [];
726
- return result;
727
- }
728
- function cleanupBlueprint(vuetifyOptions) {
729
- const blueprint = vuetifyOptions.blueprint;
730
- if (blueprint) {
731
- delete blueprint.ssr;
732
- delete blueprint.components;
733
- delete blueprint.directives;
734
- delete blueprint.locale;
735
- delete blueprint.date;
736
- delete blueprint.icons;
737
- vuetifyOptions.blueprint = blueprint;
738
- }
739
- }
740
762
 
741
763
  export { module as default };
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "vuetify-nuxt-module",
3
3
  "type": "module",
4
- "version": "0.4.3",
4
+ "version": "0.4.4",
5
5
  "packageManager": "pnpm@8.6.7",
6
- "description": "Zero-Config Nuxt Module for Vuetify ",
6
+ "description": "Zero-Config Nuxt Module for Vuetify",
7
7
  "author": "userquin <userquin@gmail.com>",
8
8
  "license": "MIT",
9
9
  "homepage": "https://github.com/userquin/vuetify-nuxt-module#readme",
@@ -114,4 +114,4 @@
114
114
  "installDependencies": false,
115
115
  "startCommand": "node .stackblitz.js && pnpm install && pnpm run dev"
116
116
  }
117
- }
117
+ }