vuetify-nuxt-module 1.0.0-alpha.3 → 1.0.0-alpha.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/dist/module.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "compatibility": {
5
5
  "nuxt": ">=3.15.0"
6
6
  },
7
- "version": "1.0.0-alpha.3",
7
+ "version": "1.0.0-alpha.4",
8
8
  "builder": {
9
9
  "@nuxt/module-builder": "1.0.2",
10
10
  "unbuild": "3.6.1"
package/dist/module.mjs CHANGED
@@ -2,22 +2,22 @@ import { addPluginTemplate, addTemplate, resolvePath, extendWebpackConfig, isNux
2
2
  import { isPackageExists, getPackageInfo } from 'local-pkg';
3
3
  import semver from 'semver';
4
4
  import { createFilter, version as version$1 } from 'vite';
5
+ import fs, { existsSync, statSync } from 'node:fs';
6
+ import { isAbsolute, resolve, relative } from 'pathe';
5
7
  import defu from 'defu';
6
8
  import { transformAssetUrls } from 'vite-plugin-vuetify';
7
9
  import { pathToFileURL } from 'node:url';
8
10
  import { generateImports, resolveVuetifyBase, isObject, normalizePath } from '@vuetify/loader-shared';
9
11
  import destr from 'destr';
10
- import { isAbsolute, relative } from 'pathe';
11
12
  import { parseQuery, parseURL } from 'ufo';
12
- import fs, { existsSync, statSync } from 'node:fs';
13
13
  import fsp, { readFile } from 'node:fs/promises';
14
14
  import path from 'upath';
15
- import { resolve, dirname, relative as relative$1 } from 'node:path';
15
+ import { resolve as resolve$1, dirname, relative as relative$1 } from 'node:path';
16
16
  import { debounce } from 'perfect-debounce';
17
17
  import process from 'node:process';
18
18
  import { createConfigLoader } from 'unconfig';
19
19
 
20
- const version = "1.0.0-alpha.3";
20
+ const version = "1.0.0-alpha.4";
21
21
 
22
22
  const VIRTUAL_VUETIFY_CONFIGURATION = "virtual:vuetify-configuration";
23
23
  const RESOLVED_VIRTUAL_VUETIFY_CONFIGURATION = `\0${VIRTUAL_VUETIFY_CONFIGURATION}`;
@@ -197,6 +197,17 @@ export default defineNuxtPlugin({
197
197
  function getTemplate(source, settings) {
198
198
  return [settings ? `@use '${settings}';` : "", `@use '${source}';`].filter(Boolean).join("\n");
199
199
  }
200
+ function resolveVuetifyConfigFile(configFile, nuxt) {
201
+ if (typeof configFile === "string" && !isAbsolute(configFile)) {
202
+ for (const layer of nuxt.options._layers) {
203
+ const resolved = resolve(layer.config.rootDir, configFile);
204
+ if (existsSync(resolved)) {
205
+ return resolved;
206
+ }
207
+ }
208
+ }
209
+ return configFile;
210
+ }
200
211
  async function configureNuxt(configKey, nuxt, ctx) {
201
212
  const {
202
213
  styles,
@@ -210,9 +221,10 @@ async function configureNuxt(configKey, nuxt, ctx) {
210
221
  if (styles !== "none" && styles !== false) {
211
222
  nuxt.options.css ??= [];
212
223
  if (typeof styles === "object" && "configFile" in styles) {
224
+ const configFile = resolveVuetifyConfigFile(styles.configFile, nuxt);
213
225
  const a = addTemplate({
214
226
  filename: "vuetify.settings.scss",
215
- getContents: async () => getTemplate("vuetify/styles", await resolvePath(styles.configFile))
227
+ getContents: async () => getTemplate("vuetify/styles", await resolvePath(configFile))
216
228
  });
217
229
  nuxt.options.css.push(a.dst);
218
230
  } else if (ctx.vuetifyGte("4.0.0")) {
@@ -424,7 +436,8 @@ async function buildConfiguration(ctx) {
424
436
  const importMapComponents = await componentsPromise;
425
437
  const componentsToImport = /* @__PURE__ */ new Map();
426
438
  for (const component of config.components) {
427
- const { from } = importMapComponents[component];
439
+ const componentEntry = importMapComponents[component];
440
+ const from = componentEntry?.from;
428
441
  if (!from) {
429
442
  logger.warn(`Component ${component} not found in Vuetify.`);
430
443
  continue;
@@ -434,16 +447,21 @@ async function buildConfiguration(ctx) {
434
447
  logger.warn(`Component ${component} not found in Vuetify, please report a new issue.`);
435
448
  continue;
436
449
  }
437
- if (!componentsToImport.has(parts[1])) {
438
- componentsToImport.set(parts[1], []);
450
+ const bucket = parts[1];
451
+ if (!bucket) {
452
+ continue;
453
+ }
454
+ if (!componentsToImport.has(bucket)) {
455
+ componentsToImport.set(bucket, []);
439
456
  }
440
- const componentsArray = componentsToImport.get(parts[1]);
457
+ const componentsArray = componentsToImport.get(bucket);
441
458
  if (!componentsArray.includes(component)) {
442
459
  componentsArray.push(component);
443
460
  }
444
461
  }
445
462
  for (const [key, component] of Object.entries(config.aliases)) {
446
- const { from } = importMapComponents[component];
463
+ const componentEntry = importMapComponents[component];
464
+ const from = componentEntry?.from;
447
465
  if (!from) {
448
466
  logger.warn(`Component ${component} not found in Vuetify.`);
449
467
  continue;
@@ -453,10 +471,14 @@ async function buildConfiguration(ctx) {
453
471
  logger.warn(`Component ${component} not found in Vuetify, please report a new issue.`);
454
472
  continue;
455
473
  }
456
- if (!componentsToImport.has(parts[1])) {
457
- componentsToImport.set(parts[1], []);
474
+ const bucket = parts[1];
475
+ if (!bucket) {
476
+ continue;
477
+ }
478
+ if (!componentsToImport.has(bucket)) {
479
+ componentsToImport.set(bucket, []);
458
480
  }
459
- const componentsArray = componentsToImport.get(parts[1]);
481
+ const componentsArray = componentsToImport.get(bucket);
460
482
  if (!componentsArray.includes(component)) {
461
483
  componentsArray.push(component);
462
484
  }
@@ -483,7 +505,8 @@ async function buildConfiguration(ctx) {
483
505
  componentsToImport.clear();
484
506
  const importMapLabComponents = await labComponentsPromise;
485
507
  for (const component of useLabComponents) {
486
- const { from } = importMapLabComponents[component];
508
+ const componentEntry = importMapLabComponents[component];
509
+ const from = componentEntry?.from;
487
510
  if (!from) {
488
511
  logger.warn(`Lab Component ${component} not found in Vuetify.`);
489
512
  continue;
@@ -493,10 +516,14 @@ async function buildConfiguration(ctx) {
493
516
  logger.warn(`Lab Component ${component} not found in Vuetify, please report a new issue.`);
494
517
  continue;
495
518
  }
496
- if (!componentsToImport.has(parts[1])) {
497
- componentsToImport.set(parts[1], []);
519
+ const bucket = parts[1];
520
+ if (!bucket) {
521
+ continue;
522
+ }
523
+ if (!componentsToImport.has(bucket)) {
524
+ componentsToImport.set(bucket, []);
498
525
  }
499
- const componentsArray = componentsToImport.get(parts[1]);
526
+ const componentsArray = componentsToImport.get(bucket);
500
527
  if (!componentsArray.includes(component)) {
501
528
  componentsArray.push(component);
502
529
  }
@@ -885,6 +912,7 @@ function vuetifyStylesPlugin(options, viteVersion, _logger) {
885
912
  const PREFIX = "vuetify-styles/";
886
913
  const SSR_PREFIX = `/@${PREFIX}`;
887
914
  const resolveCss = resolveCssFactory();
915
+ const toPath = (file) => fileImport ? pathToFileURL(file).href : normalizePath(file);
888
916
  return {
889
917
  name: "vuetify:styles:nuxt",
890
918
  enforce: "pre",
@@ -918,6 +946,9 @@ function vuetifyStylesPlugin(options, viteVersion, _logger) {
918
946
  return;
919
947
  }
920
948
  const target = await resolveCss(resolution.id);
949
+ if (target.startsWith(PREFIX) || target.startsWith(SSR_PREFIX)) {
950
+ return target;
951
+ }
921
952
  if (isNone) {
922
953
  noneFiles.add(target);
923
954
  return target;
@@ -938,7 +969,7 @@ function vuetifyStylesPlugin(options, viteVersion, _logger) {
938
969
  }
939
970
  const suffix = /\.scss/.test(target) ? ";\n" : "\n";
940
971
  const result = {
941
- code: `@use "${configFile}"${suffix}@use "${fileImport ? pathToFileURL(target).href : normalizePath(target)}"${suffix}`,
972
+ code: `@use "${toPath(configFile)}"${suffix}@use "${toPath(target)}"${suffix}`,
942
973
  map: {
943
974
  mappings: ""
944
975
  }
@@ -1284,7 +1315,7 @@ async function loadVuetifyConfiguration(cwd = process.cwd(), configOrPath = cwd,
1284
1315
  inlineConfig = configOrPath;
1285
1316
  configOrPath = process.cwd();
1286
1317
  }
1287
- const resolved = resolve(cwd, configOrPath);
1318
+ const resolved = resolve$1(cwd, configOrPath);
1288
1319
  let isFile = false;
1289
1320
  if (existsSync(resolved) && statSync(resolved).isFile()) {
1290
1321
  isFile = true;
@@ -1320,6 +1351,14 @@ async function loadVuetifyConfiguration(cwd = process.cwd(), configOrPath = cwd,
1320
1351
  });
1321
1352
  const result = await loader.load();
1322
1353
  result.config = result.config?.config === false ? Object.assign(defaults, inlineConfig) : Object.assign(defaults, result.config || inlineConfig);
1354
+ if (result.config && typeof result.config === "object" && "vuetifyOptions" in result.config) {
1355
+ const nestedOptions = result.config.vuetifyOptions;
1356
+ if (typeof nestedOptions === "object" && nestedOptions !== null) {
1357
+ console.warn('[@vuetify/nuxt-module] Detected nested "vuetifyOptions" in your configuration file. This usually happens when using a named export or wrapping options incorrectly. Please export the options directly using "export default".');
1358
+ Object.assign(result.config, nestedOptions);
1359
+ delete result.config.vuetifyOptions;
1360
+ }
1361
+ }
1323
1362
  delete result.config.config;
1324
1363
  return result;
1325
1364
  }
@@ -1547,7 +1586,7 @@ function registerWatcher(options, nuxt, ctx) {
1547
1586
  if (nuxt.options.dev) {
1548
1587
  let pageReload;
1549
1588
  nuxt.hooks.hook("builder:watch", (_event, path) => {
1550
- path = relative$1(nuxt.options.srcDir, resolve(nuxt.options.srcDir, path));
1589
+ path = relative$1(nuxt.options.srcDir, resolve$1(nuxt.options.srcDir, path));
1551
1590
  if (!pageReload && ctx.vuetifyFilesToWatch.includes(path)) {
1552
1591
  return nuxt.callHook("restart");
1553
1592
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "vuetify-nuxt-module",
3
3
  "type": "module",
4
- "version": "1.0.0-alpha.3",
4
+ "version": "1.0.0-alpha.4",
5
5
  "description": "Zero-Config Nuxt Module for Vuetify",
6
6
  "author": "userquin <userquin@gmail.com>",
7
7
  "license": "MIT",