vuetify-nuxt-module 0.4.6 β†’ 0.4.7

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,99 +1,99 @@
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
- - πŸ”₯ **Pure CSS Icons**: no more font/js icons, use the new `unocsss-mdi` icon set or build your own with UnoCSS Preset Icons
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
- Read the [πŸ“– documentation](https://vuetify-nuxt-module.netlify.app/) for a complete guide on how to configure and use this module.
90
-
91
- ## πŸ‘€ Full config
92
-
93
- Check out the [types](https://github.com/userquin/vuetify-nuxt-module/blob/main/src/types.ts).
94
-
95
- The virtual modules can be found in [configuration.d.ts](https://github.com/userquin/vuetify-nuxt-module/blob/main/configuration.d.ts) file.
96
-
97
- ## πŸ“„ License
98
-
99
- [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
+ - πŸ”₯ **Pure CSS Icons**: no more font/js icons, use the new `unocss-mdi` icon set or build your own with UnoCSS Preset Icons
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
+ Read the [πŸ“– documentation](https://vuetify-nuxt-module.netlify.app/) for a complete guide on how to configure and use this module.
90
+
91
+ ## πŸ‘€ Full config
92
+
93
+ Check out the [types](https://github.com/userquin/vuetify-nuxt-module/blob/main/src/types.ts).
94
+
95
+ The virtual modules can be found in [configuration.d.ts](https://github.com/userquin/vuetify-nuxt-module/blob/main/configuration.d.ts) file.
96
+
97
+ ## πŸ“„ License
98
+
99
+ [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.json CHANGED
@@ -4,5 +4,5 @@
4
4
  "compatibility": {
5
5
  "nuxt": "^3.0.0"
6
6
  },
7
- "version": "0.4.6"
7
+ "version": "0.4.7"
8
8
  }
package/dist/module.mjs CHANGED
@@ -6,7 +6,7 @@ import { isAbsolute, join, relative } from 'pathe';
6
6
  import { normalizePath as normalizePath$1 } from 'vite';
7
7
  import { isPackageExists } from 'local-pkg';
8
8
 
9
- const version = "0.4.6";
9
+ const version = "0.4.7";
10
10
 
11
11
  function isSubdir(root, test) {
12
12
  const relative$1 = relative(root, test);
@@ -184,7 +184,7 @@ const RESOLVED_VIRTUAL_VUETIFY_DATE_CONFIGURATION = `/@nuxt-vuetify-configuratio
184
184
  const VIRTUAL_VUETIFY_ICONS_CONFIGURATION = "virtual:vuetify-icons-configuration";
185
185
  const RESOLVED_VIRTUAL_VUETIFY_ICONS_CONFIGURATION = `/@nuxt-vuetify-configuration/${VIRTUAL_VUETIFY_ICONS_CONFIGURATION.slice("virtual:".length)}`;
186
186
 
187
- function vuetifyConfigurationPlugin(isDev, i18n, directives, labComponents, vuetifyAppOptions) {
187
+ function vuetifyConfigurationPlugin(isDev, i18n, directives, labComponents, vuetifyAppOptions, componentsPromise, labComponentsPromise, logger) {
188
188
  const {
189
189
  directives: _directives,
190
190
  date: _date,
@@ -207,7 +207,7 @@ function vuetifyConfigurationPlugin(isDev, i18n, directives, labComponents, vuet
207
207
  delete newVuetifyOptions.locale.locale;
208
208
  delete newVuetifyOptions.locale.fallback;
209
209
  }
210
- const result = buildConfiguration();
210
+ const result = await buildConfiguration();
211
211
  return `${result.imports}
212
212
 
213
213
  export const isDev = ${isDev}
@@ -222,7 +222,7 @@ export function vuetifyConfiguration() {
222
222
  }
223
223
  }
224
224
  };
225
- function buildConfiguration() {
225
+ async function buildConfiguration() {
226
226
  const dateOptions = vuetifyAppOptions.date;
227
227
  const config = {
228
228
  directives: "",
@@ -237,37 +237,95 @@ export function vuetifyConfiguration() {
237
237
  config.imports.push("import * as directives from 'vuetify/directives'");
238
238
  config.directives = "options.directives = directives";
239
239
  } else {
240
- const useDirectives = Array.isArray(directives) ? directives : [directives];
240
+ const useDirectives = Array.isArray(directives) ? [...new Set(...directives)] : [directives];
241
241
  config.imports.push(useDirectives.map((d) => `import { ${d} } from 'vuetify/directives/${d}'`).join("\n"));
242
242
  config.directives = `options.directives = {${useDirectives.join(",")}}`;
243
243
  }
244
244
  }
245
- config.imports.push(...Array.from(config.components).map((c) => `import {${c}} from 'vuetify/components/${c}'`));
245
+ const importMapComponents = await componentsPromise;
246
+ const componentsToImport = /* @__PURE__ */ new Map();
247
+ config.components.forEach((component) => {
248
+ const { from } = importMapComponents[component];
249
+ if (!from) {
250
+ logger.warn(`Component ${component} not found in Vuetify.`);
251
+ return;
252
+ }
253
+ const parts = from.split("/");
254
+ if (parts.length < 2) {
255
+ logger.warn(`Component ${component} not found in Vuetify, please report a new issue.`);
256
+ return;
257
+ }
258
+ if (!componentsToImport.has(parts[1]))
259
+ componentsToImport.set(parts[1], []);
260
+ const componentsArray = componentsToImport.get(parts[1]);
261
+ if (!componentsArray.includes(component))
262
+ componentsArray.push(component);
263
+ });
246
264
  Object.entries(config.aliases).forEach(([key, component]) => {
247
- if (!config.components.has(component)) {
248
- config.components.add(component);
249
- config.imports.push(`import {${component}} from 'vuetify/components/${component}'`);
265
+ const { from } = importMapComponents[component];
266
+ if (!from) {
267
+ logger.warn(`Component ${component} not found in Vuetify.`);
268
+ return;
269
+ }
270
+ const parts = from.split("/");
271
+ if (parts.length < 2) {
272
+ logger.warn(`Component ${component} not found in Vuetify, please report a new issue.`);
273
+ return;
250
274
  }
275
+ if (!componentsToImport.has(parts[1]))
276
+ componentsToImport.set(parts[1], []);
277
+ const componentsArray = componentsToImport.get(parts[1]);
278
+ if (!componentsArray.includes(component))
279
+ componentsArray.push(component);
251
280
  config.aliasEntries.push(`'${key}': ${component}`);
252
281
  });
282
+ componentsToImport.forEach((componentsArray, from) => {
283
+ config.imports.push(`import {${componentsArray.join(",")}} from 'vuetify/components/${from}'`);
284
+ });
253
285
  let addDatePicker = true;
254
286
  if (labComponents) {
287
+ const useLabComponents = [];
255
288
  if (typeof labComponents === "boolean") {
256
289
  config.imports.push("import * as labsComponents from 'vuetify/labs/components'");
257
290
  config.labComponents.add("*");
258
291
  addDatePicker = false;
292
+ } else if (typeof labComponents === "string") {
293
+ useLabComponents.push(labComponents);
259
294
  } else if (Array.isArray(labComponents)) {
260
- labComponents.forEach((labComponent) => {
261
- if (!config.labComponents.has(labComponent)) {
262
- config.labComponents.add(labComponent);
263
- config.imports.push(`import {${labComponent}} from 'vuetify/labs/${labComponent}'`);
295
+ useLabComponents.push(...labComponents);
296
+ }
297
+ if (useLabComponents.length) {
298
+ componentsToImport.clear();
299
+ const importMapLabComponents = await labComponentsPromise;
300
+ useLabComponents.forEach((component) => {
301
+ const { from } = importMapLabComponents[component];
302
+ if (!from) {
303
+ logger.warn(`Lab Component ${component} not found in Vuetify.`);
304
+ return;
305
+ }
306
+ const parts = from.split("/");
307
+ if (parts.length < 2) {
308
+ logger.warn(`Lab Component ${component} not found in Vuetify, please report a new issue.`);
309
+ return;
310
+ }
311
+ if (!componentsToImport.has(parts[1]))
312
+ componentsToImport.set(parts[1], []);
313
+ const componentsArray = componentsToImport.get(parts[1]);
314
+ if (!componentsArray.includes(component))
315
+ componentsArray.push(component);
316
+ config.labComponents.add(component);
317
+ });
318
+ if (dateOptions && !config.labComponents.has("VDatePicker")) {
319
+ const entry = componentsToImport.get("VDatePicker");
320
+ if (entry) {
321
+ entry.push("VDatePicker");
322
+ config.labComponents.add("VDatePicker");
264
323
  }
324
+ }
325
+ componentsToImport.forEach((componentsArray, from) => {
326
+ config.imports.push(`import {${componentsArray.join(",")}} from 'vuetify/labs/${from}'`);
265
327
  });
266
328
  addDatePicker = !config.labComponents.has("VDatePicker");
267
- } else {
268
- config.imports.push(`import {${labComponents}} from 'vuetify/labs/${labComponents}'`);
269
- config.labComponents.add(labComponents);
270
- addDatePicker = labComponents !== "VDatePicker";
271
329
  }
272
330
  }
273
331
  if (dateOptions && addDatePicker) {
@@ -744,9 +802,17 @@ const module = defineNuxtModule({
744
802
  nuxt.hook("prepare:types", ({ references }) => {
745
803
  references.push({ types: "vuetify-nuxt-module/configuration" });
746
804
  });
805
+ const vuetifyBase = resolveVuetifyBase();
806
+ async function importMapResolver() {
807
+ return JSON.parse(await readFile(resolver.resolve(vuetifyBase, "dist/json/importMap.json"), "utf-8")).components;
808
+ }
809
+ async function importMapLabResolver() {
810
+ return JSON.parse(await readFile(resolver.resolve(vuetifyBase, "dist/json/importMap-labs.json"), "utf-8")).components;
811
+ }
812
+ const componentsPromise = importMapResolver();
813
+ const labComponentsPromise = importMapLabResolver();
747
814
  nuxt.hook("components:extend", async (c) => {
748
- const vuetifyBase = resolveVuetifyBase();
749
- const { components } = JSON.parse(await readFile(resolver.resolve(vuetifyBase, "dist/json/importMap.json"), "utf-8"));
815
+ const components = await componentsPromise;
750
816
  Object.keys(components).forEach((component) => {
751
817
  const from = components[component].from;
752
818
  c.push({
@@ -787,7 +853,10 @@ const module = defineNuxtModule({
787
853
  i18n,
788
854
  directives,
789
855
  labComponents,
790
- vuetifyAppOptions
856
+ vuetifyAppOptions,
857
+ componentsPromise,
858
+ labComponentsPromise,
859
+ logger
791
860
  ));
792
861
  viteInlineConfig.plugins.push(vuetifyIconsPlugin(
793
862
  nuxt.options.dev,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "vuetify-nuxt-module",
3
3
  "type": "module",
4
- "version": "0.4.6",
4
+ "version": "0.4.7",
5
5
  "packageManager": "pnpm@8.6.8",
6
6
  "description": "Zero-Config Nuxt Module for Vuetify",
7
7
  "author": "userquin <userquin@gmail.com>",
@@ -125,4 +125,4 @@
125
125
  "installDependencies": false,
126
126
  "startCommand": "node .stackblitz.js && pnpm install && pnpm run dev"
127
127
  }
128
- }
128
+ }