vuetify-nuxt-module 0.4.3 → 0.4.5

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,98 @@
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
+ <a href="https://vuetify-nuxt-module.netlify.app/" target="__blank">
17
+ <img src="https://img.shields.io/static/v1?label=&message=docs%20%26%20guides&color=2e859c" alt="Docs & Guides">
18
+ </a>
19
+ <br>
20
+ <a href="https://github.com/userquin/vuetify-nuxt-module" target="__blank">
21
+ <img alt="GitHub stars" src="https://img.shields.io/github/stars/userquin/vuetify-nuxt-module?style=social">
22
+ </a>
23
+ </p>
24
+
25
+ <br>
26
+
27
+ ## 🚀 Features
28
+
29
+ - 📖 [**Documentation & guides**](https://vuetify-nuxt-module.netlify.app/)
30
+ - 👌 **Zero-Config**: sensible built-in default [Vuetify](https://vuetifyjs.com/) configuration for common use cases
31
+ - 🔌 **Extensible**: expose the ability to customize the Vuetify configuration via [Nuxt Plugin Hooks](https://nuxt.com/docs/guide/going-further/hooks#usage-with-plugins)
32
+ - **Fully Tree Shakable**: by default, only the needed Vuetify components are imported
33
+ - 🛠️ **Versatile**: custom Vuetify [directives](https://vuetifyjs.com/en/getting-started/installation/#manual-steps) and [labs components](https://vuetifyjs.com/en/labs/introduction/) registration
34
+ - **Configurable Styles**: configure your variables using [Vuetify SASS Variables](https://vuetifyjs.com/en/features/sass-variables/)
35
+ - 💥 **SSR**: automatic SSR detection and configuration
36
+ - 😃 **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
37
+ - 🎭 **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
38
+ - 📦 **Multiple Icon Sets**: register [multiple icon sets](https://vuetifyjs.com/en/features/icon-fonts/#multiple-icon-sets)
39
+ - 🌍 **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
40
+ - 📆 **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
41
+ - ⚙️ **Auto-Import Vuetify Composables**: you don't need to import Vuetify composables manually, they are automatically imported for you
42
+ - 🎨 **Vuetify Blueprints**: use [Vuetify Blueprints](https://vuetifyjs.com/en/features/blueprints/) to quickly scaffold components
43
+ - 🔩 **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)
44
+ - 👀 **Nuxt DevTools**: ready to inspect your Vuetify styles with the [Nuxt DevTools](https://github.com/nuxt/devtools) inspector
45
+ - 🦾 **Type Strong**: written in [TypeScript](https://www.typescriptlang.org/)
46
+
47
+ ## 📦 Install
48
+
49
+ > Requires Vite, will not work with Webpack
50
+
51
+ ```bash
52
+ npm i vuetify-nuxt-module -D
53
+
54
+ # yarn
55
+ yarn add vuetify-nuxt-module -D
56
+
57
+ # pnpm
58
+ pnpm add vuetify-nuxt-module -D
59
+ ```
60
+
61
+ [![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/github/userquin/vuetify-nuxt-module)
62
+
63
+ ## 🦄 Usage
64
+
65
+ > `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.
66
+
67
+ Add `vuetify-nuxt-module` module to `nuxt.config.ts` and configure it:
68
+
69
+ ```ts
70
+ // Nuxt config file
71
+ import { defineNuxtConfig } from 'nuxt/config'
72
+
73
+ export default defineNuxtConfig({
74
+ modules: [
75
+ 'vuetify-nuxt-module'
76
+ ],
77
+ vuetify: {
78
+ moduleOptions: {
79
+ /* module specific options */
80
+ },
81
+ vuetifyOptions: {
82
+ /* vuetify options */
83
+ }
84
+ }
85
+ })
86
+ ```
87
+
88
+ Read the [📖 documentation](https://vuetify-nuxt-module.netlify.app/) for a complete guide on how to configure and use this module.
89
+
90
+ ## 👀 Full config
91
+
92
+ Check out the [types](https://github.com/userquin/vuetify-nuxt-module/blob/main/src/types.ts).
93
+
94
+ The virtual modules can be found in [configuration.d.ts](https://github.com/userquin/vuetify-nuxt-module/blob/main/configuration.d.ts) file.
95
+
96
+ ## 📄 License
97
+
98
+ [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
@@ -34,8 +34,8 @@ interface DateOptions {
34
34
  */
35
35
  locale?: Record<string, any>;
36
36
  }
37
- type IconSetName = 'mdi' | 'fa' | 'fa4' | 'md' | 'mdi-svg' | 'fa-svg' | 'custom';
38
- type IconFontName = 'mdi' | 'fa' | 'fa4' | 'md';
37
+ type IconSetName = 'mdi' | 'fa' | 'fa4' | 'md' | 'mdi-svg' | 'fa-svg' | 'unocss-mdi' | 'custom';
38
+ type IconFontName = 'unocss-mdi' | 'mdi' | 'fa' | 'fa4' | 'md';
39
39
  interface JSSVGIconSet {
40
40
  aliases?: Record<string, string>;
41
41
  }
@@ -68,7 +68,16 @@ interface FontIconSet {
68
68
  cdn?: string;
69
69
  }
70
70
  interface IconsOptions {
71
+ /**
72
+ * @default 'mdi'
73
+ */
71
74
  defaultSet: IconSetName;
75
+ /**
76
+ * The prefix for UnoCSS Preset Icons.
77
+ *
78
+ * @default 'i-'
79
+ */
80
+ unocssIconPrefix?: string;
72
81
  sets?: IconFontName | IconFontName[] | FontIconSet[];
73
82
  svg?: {
74
83
  mdi?: JSSVGIconSet;
@@ -174,6 +183,14 @@ interface ModuleOptions {
174
183
  */
175
184
  vuetifyOptions?: VOptions;
176
185
  }
186
+ declare module '@nuxt/schema' {
187
+ interface NuxtConfig {
188
+ vuetify?: ModuleOptions;
189
+ }
190
+ interface NuxtHooks {
191
+ 'vuetify:registerModule': (registerModule: (config: ModuleOptions) => void) => void;
192
+ }
193
+ }
177
194
  declare module '#app' {
178
195
  interface NuxtApp {
179
196
  $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.5"
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.5";
10
10
 
11
11
  function isSubdir(root, test) {
12
12
  const relative$1 = relative(root, test);
@@ -333,21 +333,26 @@ export function dateConfiguration() {
333
333
  }
334
334
  }
335
335
 
336
- const cssFonts = ["mdi", "md", "fa", "fa4"];
336
+ const cssFonts = ["unocss-mdi", "mdi", "md", "fa", "fa4"];
337
337
  const iconsPackageNames = {
338
- mdi: { name: "@mdi/font", css: "@mdi/font/css/materialdesignicons.css" },
339
- md: { name: "material-design-icons-iconfont", css: "@mdi/font/css/materialdesignicons.css" },
340
- fa: { name: "@fortawesome/fontawesome-free", css: "@fortawesome/fontawesome-free/css/all.css" },
341
- fa4: { name: "font-awesome@4.7.0", css: "font-awesome/css/font-awesome.min.css" }
338
+ "unocss-mdi": { name: "@mdi/font", css: "" },
339
+ "mdi": { name: "@mdi/font", css: "@mdi/font/css/materialdesignicons.css" },
340
+ "md": { name: "material-design-icons-iconfont", css: "@mdi/font/css/materialdesignicons.css" },
341
+ "fa": { name: "@fortawesome/fontawesome-free", css: "@fortawesome/fontawesome-free/css/all.css" },
342
+ "fa4": { name: "font-awesome@4.7.0", css: "font-awesome/css/font-awesome.min.css" }
342
343
  };
343
344
  const iconsCDN = {
344
- mdi: "https://cdn.jsdelivr.net/npm/@mdi/font@5.x/css/materialdesignicons.min.css",
345
- md: "https://fonts.googleapis.com/css?family=Material+Icons",
346
- fa: "https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@latest/css/all.min.css",
347
- fa4: "https://cdn.jsdelivr.net/npm/font-awesome@4.x/css/font-awesome.min.css"
345
+ "unocss-mdi": "",
346
+ "mdi": "https://cdn.jsdelivr.net/npm/@mdi/font@5.x/css/materialdesignicons.min.css",
347
+ "md": "https://fonts.googleapis.com/css?family=Material+Icons",
348
+ "fa": "https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@latest/css/all.min.css",
349
+ "fa4": "https://cdn.jsdelivr.net/npm/font-awesome@4.x/css/font-awesome.min.css"
348
350
  };
349
351
  const disabledResolvedIcons = Object.freeze({
350
352
  enabled: false,
353
+ unocss: false,
354
+ unocssAliases: false,
355
+ unocssIconPrefix: "i-",
351
356
  imports: [],
352
357
  aliases: [],
353
358
  sets: [],
@@ -355,7 +360,7 @@ const disabledResolvedIcons = Object.freeze({
355
360
  local: [],
356
361
  svg: {}
357
362
  });
358
- function prepareIcons(logger, vuetifyOptions) {
363
+ function prepareIcons(unocssPresent, logger, vuetifyOptions) {
359
364
  if (vuetifyOptions.icons === false)
360
365
  return disabledResolvedIcons;
361
366
  const icons = vuetifyOptions.icons || {};
@@ -364,9 +369,12 @@ function prepareIcons(logger, vuetifyOptions) {
364
369
  defaultSet = icons.defaultSet = "mdi";
365
370
  if (!sets && defaultSet !== "mdi-svg" && defaultSet !== "fa-svg" && defaultSet !== "custom")
366
371
  sets = [{ name: defaultSet || "mdi" }];
367
- sets = sets ? convertFontSetsToObjectNotation(sets) : void 0;
372
+ sets = sets ? convertFontSetsToObjectNotation(sets) : [];
368
373
  const resolvedIcons = {
369
374
  enabled: true,
375
+ unocss: unocssPresent && (defaultSet === "unocss-mdi" || sets.some((s) => s.name === "unocss-mdi")),
376
+ unocssAliases: defaultSet === "unocss-mdi",
377
+ unocssIconPrefix: icons.unocssIconPrefix ?? "i-",
370
378
  defaultSet,
371
379
  sets: [],
372
380
  aliases: [],
@@ -378,7 +386,14 @@ function prepareIcons(logger, vuetifyOptions) {
378
386
  }
379
387
  };
380
388
  if (sets) {
389
+ if (!unocssPresent && defaultSet === "unocss-mdi") {
390
+ logger.warn("Configured unocss-mdi as default icon set and @unocss/nuxt is not installed, reverting configuration to use mdi icon set: install @unocss/nuxt module or change the default icon set!");
391
+ defaultSet = "mdi";
392
+ sets = sets.filter((s) => s.name !== "unocss-mdi");
393
+ }
381
394
  sets.filter((s) => cssFonts.includes(s.name)).map((s) => s.name).forEach((name) => {
395
+ if (name === "unocss-mdi")
396
+ return;
382
397
  resolvedIcons.imports.push(`import {${name === defaultSet ? "aliases," : ""}${name}} from 'vuetify/iconsets/${name}'`);
383
398
  resolvedIcons.sets.push(name);
384
399
  if (isPackageExists(iconsPackageNames[name].name))
@@ -386,6 +401,13 @@ function prepareIcons(logger, vuetifyOptions) {
386
401
  else
387
402
  resolvedIcons.cdn.push(iconsCDN[name]);
388
403
  });
404
+ if (resolvedIcons.unocss && defaultSet === "unocss-mdi") {
405
+ if (!resolvedIcons.sets.includes("mdi")) {
406
+ resolvedIcons.sets.push("mdi");
407
+ resolvedIcons.imports.push("import {mdi} from 'vuetify/iconsets/mdi'");
408
+ }
409
+ resolvedIcons.defaultSet = "mdi";
410
+ }
389
411
  }
390
412
  let faSvg = icons.svg?.fa;
391
413
  if (defaultSet === "fa-svg" || faSvg) {
@@ -445,7 +467,7 @@ function prepareIcons(logger, vuetifyOptions) {
445
467
  logger.warn("Missing @mdi/js dependency, install it!");
446
468
  }
447
469
  }
448
- if (!resolvedIcons.local?.length && !resolvedIcons.cdn?.length && !resolvedIcons.svg?.mdi && !resolvedIcons.svg?.fa?.length) {
470
+ if (defaultSet !== "custom" && !resolvedIcons.unocss && !resolvedIcons.local?.length && !resolvedIcons.cdn?.length && !resolvedIcons.svg?.mdi && !resolvedIcons.svg?.fa?.length) {
449
471
  logger.warn("No icons found, icons disabled!");
450
472
  return disabledResolvedIcons;
451
473
  }
@@ -484,7 +506,7 @@ export function iconsConfiguration() {
484
506
  }
485
507
  `;
486
508
  }
487
- const { aliases, fa, defaultSet, imports, sets } = await iconsOptionsPromise;
509
+ const { unocss, aliases, fa, defaultSet, imports, sets } = await iconsOptionsPromise;
488
510
  if (!defaultSet) {
489
511
  return `export const isDev = ${isDev}
490
512
  export function iconsConfiguration() {
@@ -493,7 +515,6 @@ export function iconsConfiguration() {
493
515
  `;
494
516
  }
495
517
  return `${imports}
496
-
497
518
  export const isDev = ${isDev}
498
519
  export function iconsConfiguration() {
499
520
  ${fa.map((f) => ` ${f}`).join("\n")}
@@ -503,6 +524,7 @@ ${fa.map((f) => ` ${f}`).join("\n")}
503
524
  sets: { ${sets} }
504
525
  }
505
526
  }
527
+ ${unocss}
506
528
  `;
507
529
  }
508
530
  }
@@ -510,6 +532,7 @@ ${fa.map((f) => ` ${f}`).join("\n")}
510
532
  async function prepareIcons() {
511
533
  if (!resolvedIcons.enabled) {
512
534
  return {
535
+ unocss: "",
513
536
  defaultSet: void 0,
514
537
  imports: "",
515
538
  sets: "",
@@ -524,9 +547,56 @@ ${fa.map((f) => ` ${f}`).join("\n")}
524
547
  ...aliases,
525
548
  ${alias.join(",\n")}
526
549
  },
550
+ `;
551
+ }
552
+ let unocss = "";
553
+ if (resolvedIcons.unocss && resolvedIcons.unocssAliases) {
554
+ resolvedIcons.imports.unshift("// @unocss-include");
555
+ const prefix = `${resolvedIcons.unocssIconPrefix}mdi:`;
556
+ unocss = `const aliases = ${JSON.stringify({
557
+ collapse: `${prefix}chevron-up`,
558
+ complete: `${prefix}check`,
559
+ cancel: `${prefix}close-circle`,
560
+ close: `${prefix}close`,
561
+ delete: `${prefix}close-circle`,
562
+ // delete (e.g. v-chip close)
563
+ clear: `${prefix}close-circle`,
564
+ success: `${prefix}check-circle`,
565
+ info: `${prefix}information`,
566
+ warning: `${prefix}alert-circle`,
567
+ error: `${prefix}close-circle`,
568
+ prev: `${prefix}chevron-left`,
569
+ next: `${prefix}chevron-right`,
570
+ checkboxOn: `${prefix}checkbox-marked`,
571
+ checkboxOff: `${prefix}checkbox-blank-outline`,
572
+ checkboxIndeterminate: `${prefix}minus-box`,
573
+ delimiter: `${prefix}circle`,
574
+ // for carousel
575
+ sortAsc: `${prefix}arrow-up`,
576
+ sortDesc: `${prefix}arrow-down`,
577
+ expand: `${prefix}chevron-down`,
578
+ menu: `${prefix}menu`,
579
+ subgroup: `${prefix}menu-down`,
580
+ dropdown: `${prefix}menu-down`,
581
+ radioOn: `${prefix}radiobox-marked`,
582
+ radioOff: `${prefix}radiobox-blank`,
583
+ edit: `${prefix}pencil`,
584
+ ratingEmpty: `${prefix}star-outline`,
585
+ ratingFull: `${prefix}star`,
586
+ ratingHalf: `${prefix}star-half-full`,
587
+ loading: `${prefix}cached`,
588
+ first: `${prefix}page-first`,
589
+ last: `${prefix}page-last`,
590
+ unfold: `${prefix}unfold-more-horizontal`,
591
+ file: `${prefix}paperclip`,
592
+ plus: `${prefix}plus`,
593
+ minus: `${prefix}minus`,
594
+ calendar: `${prefix}calendar`
595
+ })}
527
596
  `;
528
597
  }
529
598
  return {
599
+ unocss,
530
600
  fa: resolvedIcons.svg?.fa ?? [],
531
601
  defaultSet: resolvedIcons.defaultSet,
532
602
  imports: Object.values(resolvedIcons.imports).join("\n"),
@@ -545,6 +615,41 @@ function toKebabCase(str = "") {
545
615
  }
546
616
  toKebabCase.cache = /* @__PURE__ */ new Map();
547
617
 
618
+ function detectDate() {
619
+ const result = [];
620
+ return result;
621
+ }
622
+ function cleanupBlueprint(vuetifyOptions) {
623
+ const blueprint = vuetifyOptions.blueprint;
624
+ if (blueprint) {
625
+ delete blueprint.ssr;
626
+ delete blueprint.components;
627
+ delete blueprint.directives;
628
+ delete blueprint.locale;
629
+ delete blueprint.date;
630
+ delete blueprint.icons;
631
+ vuetifyOptions.blueprint = blueprint;
632
+ }
633
+ }
634
+
635
+ async function mergeVuetifyModules(options, nuxt) {
636
+ const moduleOptions = [];
637
+ await nuxt.callHook("vuetify:registerModule", (layerModuleOptions) => moduleOptions.push(layerModuleOptions));
638
+ if (nuxt.options._layers.length > 1) {
639
+ nuxt.options._layers.forEach((layer, idx) => {
640
+ if (idx > 0 && layer.config.vuetify)
641
+ moduleOptions.push(layer.config.vuetify);
642
+ });
643
+ }
644
+ moduleOptions.push(options);
645
+ if (moduleOptions.length > 1) {
646
+ const [base, ...rest] = moduleOptions;
647
+ return defu(base, ...rest);
648
+ } else {
649
+ return options;
650
+ }
651
+ }
652
+
548
653
  const CONFIG_KEY = "vuetify";
549
654
  const logger = useLogger(`nuxt:${CONFIG_KEY}`);
550
655
  const module = defineNuxtModule({
@@ -565,9 +670,12 @@ const module = defineNuxtModule({
565
670
  styles: true
566
671
  }
567
672
  }),
568
- setup(options, nuxt) {
673
+ async setup(options, nuxt) {
569
674
  var _a, _b;
675
+ if (!isNuxt3(nuxt))
676
+ logger.error(`Cannot support nuxt version: ${getNuxtVersion(nuxt)}`);
570
677
  const resolver = createResolver(import.meta.url);
678
+ options = await mergeVuetifyModules(options, nuxt);
571
679
  const { vuetifyOptions = {} } = options;
572
680
  const {
573
681
  directives = false,
@@ -609,7 +717,7 @@ const module = defineNuxtModule({
609
717
  }
610
718
  }
611
719
  nuxt.options.build.transpile.push(CONFIG_KEY);
612
- const icons = prepareIcons(logger, vuetifyOptions);
720
+ const icons = prepareIcons(hasNuxtModule("@unocss/nuxt"), logger, vuetifyOptions);
613
721
  (_a = nuxt.options).css ?? (_a.css = []);
614
722
  if (typeof styles === "string" && ["sass", "expose"].includes(styles))
615
723
  nuxt.options.css.unshift("vuetify/styles/main.sass");
@@ -721,21 +829,5 @@ function checkVuetifyPlugins(config) {
721
829
  if (plugin)
722
830
  throw new Error("Remove vite-plugin-vuetify plugin from Vite Plugins entry in Nuxt config file!");
723
831
  }
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
832
 
741
833
  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.5",
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",
@@ -46,10 +46,14 @@
46
46
  "dev:build:multiple-json": "MULTIPLE_LANG_FILES=true nuxi build playground",
47
47
  "dev:generate:multiple-json": "MULTIPLE_LANG_FILES=true nuxi generate playground",
48
48
  "dev:preview": "nuxi preview playground",
49
+ "docs:dev": "pnpm -C docs run dev",
50
+ "docs:build": "pnpm -C docs run build",
51
+ "docs:serve": "pnpm -C docs run serve",
49
52
  "lint": "eslint .",
50
53
  "lint:fix": "nr lint --fix",
51
54
  "test": "vitest run",
52
55
  "test:watch": "vitest watch",
56
+ "postinstall": "pnpm dev:prepare",
53
57
  "prepublishOnly": "pnpm build",
54
58
  "release": "bumpp && npm publish"
55
59
  },
@@ -71,6 +75,7 @@
71
75
  "@fortawesome/fontawesome-svg-core": "^6.4.0",
72
76
  "@fortawesome/free-solid-svg-icons": "^6.4.0",
73
77
  "@fortawesome/vue-fontawesome": "^3.0.3",
78
+ "@iconify-json/mdi": "^1.1.53",
74
79
  "@mdi/js": "^7.2.96",
75
80
  "@nuxt/devtools": "^0.6.7",
76
81
  "@nuxt/module-builder": "^0.4.0",
@@ -79,6 +84,7 @@
79
84
  "@nuxtjs/i18n": "^8.0.0-beta.13",
80
85
  "@parcel/watcher": "^2.1.0",
81
86
  "@types/node": "^18",
87
+ "@unocss/nuxt": "^0.53.5",
82
88
  "bumpp": "^9.1.1",
83
89
  "eslint": "^8.43.0",
84
90
  "luxon": "^3.3.0",
@@ -114,4 +120,4 @@
114
120
  "installDependencies": false,
115
121
  "startCommand": "node .stackblitz.js && pnpm install && pnpm run dev"
116
122
  }
117
- }
123
+ }