vuetify-nuxt-module 1.0.0-beta.1 → 1.0.0-beta.3
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 +1 -1
- package/dist/module.json +1 -1
- package/dist/module.mjs +135 -79
- package/package.json +1 -3
package/README.md
CHANGED
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
> Requires Vite, will not work with Webpack
|
|
53
53
|
|
|
54
54
|
```bash
|
|
55
|
-
npx
|
|
55
|
+
npx nuxt module add vuetify-nuxt-module
|
|
56
56
|
```
|
|
57
57
|
|
|
58
58
|
[](https://stackblitz.com/github/userquin/vuetify-nuxt-module)
|
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -1,24 +1,22 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { pathToFileURL, fileURLToPath } from 'node:url';
|
|
2
|
+
import { addPluginTemplate, resolvePath, addTemplate, extendWebpackConfig, isNuxtMajorVersion, addImports, addPlugin, addVitePlugin, useLogger, defineNuxtModule, getNuxtVersion, createResolver, hasNuxtModule } from '@nuxt/kit';
|
|
3
3
|
import semver from 'semver';
|
|
4
4
|
import { createFilter, version as version$1 } from 'vite';
|
|
5
|
-
import fs, { existsSync, statSync, readFileSync, readdirSync, rmSync, mkdirSync, writeFileSync } from 'node:fs';
|
|
6
|
-
import { isAbsolute, resolve, relative } from 'pathe';
|
|
7
5
|
import defu from 'defu';
|
|
8
6
|
import { transformAssetUrls } from 'vite-plugin-vuetify';
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
7
|
+
import { createHash } from 'node:crypto';
|
|
8
|
+
import fs, { existsSync, readdirSync, rmSync, statSync, readFileSync, mkdirSync, writeFileSync } from 'node:fs';
|
|
9
|
+
import { isAbsolute, resolve, join, relative, dirname } from 'pathe';
|
|
10
|
+
import { generateImports, isObject, resolveVuetifyBase, normalizePath } from '@vuetify/loader-shared';
|
|
11
11
|
import destr from 'destr';
|
|
12
12
|
import { parseQuery, parseURL } from 'ufo';
|
|
13
13
|
import fsp, { readFile } from 'node:fs/promises';
|
|
14
14
|
import path from 'upath';
|
|
15
|
-
import { resolve as resolve$1, dirname, join, relative as relative$1 } from 'node:path';
|
|
16
15
|
import { debounce } from 'perfect-debounce';
|
|
17
16
|
import process from 'node:process';
|
|
18
17
|
import { createConfigLoader } from 'unconfig';
|
|
19
|
-
import { createHash } from 'node:crypto';
|
|
20
18
|
|
|
21
|
-
const version = "1.0.0-beta.
|
|
19
|
+
const version = "1.0.0-beta.3";
|
|
22
20
|
|
|
23
21
|
const VIRTUAL_VUETIFY_CONFIGURATION = "virtual:vuetify-configuration";
|
|
24
22
|
const RESOLVED_VIRTUAL_VUETIFY_CONFIGURATION = `\0${VIRTUAL_VUETIFY_CONFIGURATION}`;
|
|
@@ -128,6 +126,64 @@ function normalizeTransformAssetUrlsAttrs(attrs) {
|
|
|
128
126
|
return [...result];
|
|
129
127
|
}
|
|
130
128
|
|
|
129
|
+
function resolveVuetifyConfigFile(configFile, nuxt) {
|
|
130
|
+
if (typeof configFile === "string" && !isAbsolute(configFile)) {
|
|
131
|
+
for (const layer of nuxt.options._layers) {
|
|
132
|
+
const resolved = resolve(layer.config.srcDir, configFile);
|
|
133
|
+
if (existsSync(resolved)) {
|
|
134
|
+
return resolved;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
return configFile;
|
|
139
|
+
}
|
|
140
|
+
function createStylesCacheHash(vuetifyVersion, viteVersion, configContent, configFile) {
|
|
141
|
+
return createHash("sha256").update(vuetifyVersion).update(viteVersion).update(configContent).update(configFile).digest("hex").slice(0, 8);
|
|
142
|
+
}
|
|
143
|
+
function resolveStylesCachePaths(rootDir, hash) {
|
|
144
|
+
const stylesDir = resolve(rootDir, "node_modules/.cache/vuetify-nuxt-module/styles");
|
|
145
|
+
const cacheDir = join(stylesDir, hash);
|
|
146
|
+
return {
|
|
147
|
+
stylesDir,
|
|
148
|
+
cacheDir
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
function cleanupOldStylesCaches(stylesDir, currentHash) {
|
|
152
|
+
if (!existsSync(stylesDir)) {
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
const dirents = readdirSync(stylesDir, { withFileTypes: true });
|
|
156
|
+
for (const dirent of dirents) {
|
|
157
|
+
if (dirent.isDirectory() && dirent.name !== currentHash) {
|
|
158
|
+
rmSync(join(stylesDir, dirent.name), { recursive: true, force: true });
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
function collectVuetifyCssFiles(vuetifyBase) {
|
|
163
|
+
const files = [];
|
|
164
|
+
findCssFiles(join(vuetifyBase, "lib/components"), files);
|
|
165
|
+
findCssFiles(join(vuetifyBase, "lib/styles"), files);
|
|
166
|
+
return files;
|
|
167
|
+
}
|
|
168
|
+
function findCssFiles(dir, fileList = []) {
|
|
169
|
+
if (!existsSync(dir)) {
|
|
170
|
+
return fileList;
|
|
171
|
+
}
|
|
172
|
+
const files = readdirSync(dir);
|
|
173
|
+
for (const file of files) {
|
|
174
|
+
const filePath = join(dir, file);
|
|
175
|
+
const stat = statSync(filePath);
|
|
176
|
+
if (stat.isDirectory()) {
|
|
177
|
+
findCssFiles(filePath, fileList);
|
|
178
|
+
} else {
|
|
179
|
+
if (file.endsWith(".css")) {
|
|
180
|
+
fileList.push(filePath);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
return fileList;
|
|
185
|
+
}
|
|
186
|
+
|
|
131
187
|
function addVuetifyNuxtPlugins(nuxt, ctx) {
|
|
132
188
|
addVuetifyNuxtPlugin(nuxt, ctx, "client");
|
|
133
189
|
addVuetifyNuxtPlugin(nuxt, ctx, "server");
|
|
@@ -198,17 +254,6 @@ export default defineNuxtPlugin({
|
|
|
198
254
|
function getTemplate(source, settings) {
|
|
199
255
|
return [settings ? `@use '${settings}';` : "", `@use '${source}';`].filter(Boolean).join("\n");
|
|
200
256
|
}
|
|
201
|
-
function resolveVuetifyConfigFile(configFile, nuxt) {
|
|
202
|
-
if (typeof configFile === "string" && !isAbsolute(configFile)) {
|
|
203
|
-
for (const layer of nuxt.options._layers) {
|
|
204
|
-
const resolved = resolve(layer.config.rootDir, configFile);
|
|
205
|
-
if (existsSync(resolved)) {
|
|
206
|
-
return resolved;
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
return configFile;
|
|
211
|
-
}
|
|
212
257
|
async function configureNuxt(configKey, nuxt, ctx) {
|
|
213
258
|
const {
|
|
214
259
|
styles,
|
|
@@ -223,9 +268,10 @@ async function configureNuxt(configKey, nuxt, ctx) {
|
|
|
223
268
|
nuxt.options.css ??= [];
|
|
224
269
|
if (typeof styles === "object" && "configFile" in styles) {
|
|
225
270
|
const configFile = resolveVuetifyConfigFile(styles.configFile, nuxt);
|
|
271
|
+
ctx.stylesConfigFile = await resolvePath(configFile);
|
|
226
272
|
const a = addTemplate({
|
|
227
273
|
filename: "vuetify.settings.scss",
|
|
228
|
-
getContents: async () => getTemplate("vuetify/styles",
|
|
274
|
+
getContents: async () => getTemplate("vuetify/styles", ctx.stylesConfigFile)
|
|
229
275
|
});
|
|
230
276
|
nuxt.options.css.push(a.dst);
|
|
231
277
|
} else if (ctx.vuetifyGte("4.0.0")) {
|
|
@@ -903,8 +949,8 @@ function vuetifySSRClientHintsPlugin(ctx) {
|
|
|
903
949
|
|
|
904
950
|
function vuetifyStylesPlugin(ctx) {
|
|
905
951
|
let configFile;
|
|
952
|
+
let vuetifyBase;
|
|
906
953
|
const options = { styles: ctx.moduleOptions.styles };
|
|
907
|
-
const vuetifyBase = resolveVuetifyBase();
|
|
908
954
|
const noneFiles = /* @__PURE__ */ new Set();
|
|
909
955
|
let isNone = false;
|
|
910
956
|
let sassVariables = false;
|
|
@@ -923,10 +969,11 @@ function vuetifyStylesPlugin(ctx) {
|
|
|
923
969
|
if (isObject(options.styles) && "configFile" in options.styles) {
|
|
924
970
|
sassVariables = true;
|
|
925
971
|
fileImport = semver.gt(ctx.viteVersion, "5.4.2");
|
|
926
|
-
configFile = await resolvePath(options.styles.configFile);
|
|
972
|
+
configFile = ctx.stylesConfigFile ?? await resolvePath(options.styles.configFile);
|
|
927
973
|
} else {
|
|
928
974
|
isNone = options.styles === "none";
|
|
929
975
|
}
|
|
976
|
+
vuetifyBase = await resolveVuetifyBase();
|
|
930
977
|
},
|
|
931
978
|
async resolveId(source, importer, { custom, ssr }) {
|
|
932
979
|
if (!sassVariables) {
|
|
@@ -939,7 +986,7 @@ function vuetifyStylesPlugin(ctx) {
|
|
|
939
986
|
const idx = source.indexOf("?");
|
|
940
987
|
return idx === -1 ? source : source.slice(0, idx);
|
|
941
988
|
}
|
|
942
|
-
if (importer && source.endsWith(".css") && isSubdir(vuetifyBase, path.isAbsolute(source) ? source : importer)) {
|
|
989
|
+
if (vuetifyBase && importer && source.endsWith(".css") && isSubdir(vuetifyBase, path.isAbsolute(source) ? source : importer)) {
|
|
943
990
|
let resolutionId;
|
|
944
991
|
if (source.startsWith(".")) {
|
|
945
992
|
resolutionId = path.resolve(path.dirname(importer), source);
|
|
@@ -972,6 +1019,9 @@ function vuetifyStylesPlugin(ctx) {
|
|
|
972
1019
|
},
|
|
973
1020
|
load(id) {
|
|
974
1021
|
if (sassVariables) {
|
|
1022
|
+
if (!vuetifyBase) {
|
|
1023
|
+
return;
|
|
1024
|
+
}
|
|
975
1025
|
const target = id.startsWith(PREFIX) ? path.resolve(vuetifyBase, id.slice(PREFIX.length)) : id.startsWith(SSR_PREFIX) ? path.resolve(vuetifyBase, id.slice(SSR_PREFIX.length)) : void 0;
|
|
976
1026
|
if (target) {
|
|
977
1027
|
const suffix = /\.scss/.test(target) ? ";\n" : "\n";
|
|
@@ -1016,7 +1066,25 @@ function isSubdir(root, test) {
|
|
|
1016
1066
|
return relative$1 && !relative$1.startsWith("..") && !isAbsolute(relative$1);
|
|
1017
1067
|
}
|
|
1018
1068
|
|
|
1019
|
-
function
|
|
1069
|
+
async function loadPackageJSON(name, parentURL = import.meta.url) {
|
|
1070
|
+
try {
|
|
1071
|
+
const packageJsonUrl = import.meta.resolve(`${name}/package.json`, parentURL);
|
|
1072
|
+
const packageJsonPath = fileURLToPath(packageJsonUrl);
|
|
1073
|
+
return JSON.parse(await readFile(packageJsonPath, "utf8"));
|
|
1074
|
+
} catch {
|
|
1075
|
+
return null;
|
|
1076
|
+
}
|
|
1077
|
+
}
|
|
1078
|
+
function isPackageExists(name, parentURL = import.meta.url) {
|
|
1079
|
+
try {
|
|
1080
|
+
import.meta.resolve(name, parentURL);
|
|
1081
|
+
return true;
|
|
1082
|
+
} catch {
|
|
1083
|
+
return false;
|
|
1084
|
+
}
|
|
1085
|
+
}
|
|
1086
|
+
|
|
1087
|
+
function detectDate(packageResolveFrom) {
|
|
1020
1088
|
const result = [];
|
|
1021
1089
|
for (const adapter of [
|
|
1022
1090
|
"date-fns",
|
|
@@ -1028,7 +1096,7 @@ function detectDate() {
|
|
|
1028
1096
|
"jalaali",
|
|
1029
1097
|
"hijri"
|
|
1030
1098
|
]) {
|
|
1031
|
-
if (isPackageExists(`@date-io/${adapter}
|
|
1099
|
+
if (isPackageExists(`@date-io/${adapter}`, packageResolveFrom)) {
|
|
1032
1100
|
result.push(adapter);
|
|
1033
1101
|
}
|
|
1034
1102
|
}
|
|
@@ -1081,7 +1149,7 @@ function configureVite(configKey, nuxt, ctx) {
|
|
|
1081
1149
|
if (!ctx.moduleOptions.disableModernSassCompiler) {
|
|
1082
1150
|
const enableModernSassCompiler = semver.gte(ctx.viteVersion, "5.4.0") && semver.lt(ctx.viteVersion, "7.0.0-0");
|
|
1083
1151
|
if (enableModernSassCompiler) {
|
|
1084
|
-
const sassEmbedded = isPackageExists("sass-embedded");
|
|
1152
|
+
const sassEmbedded = isPackageExists("sass-embedded", ctx.packageResolveFrom);
|
|
1085
1153
|
if (sassEmbedded) {
|
|
1086
1154
|
viteInlineConfig.css ??= {};
|
|
1087
1155
|
viteInlineConfig.css.preprocessorOptions ??= {};
|
|
@@ -1165,7 +1233,7 @@ const disabledResolvedIcons = Object.freeze({
|
|
|
1165
1233
|
local: [],
|
|
1166
1234
|
svg: {}
|
|
1167
1235
|
});
|
|
1168
|
-
function prepareIcons(unocssPresent, logger, vuetifyOptions) {
|
|
1236
|
+
function prepareIcons(unocssPresent, logger, vuetifyOptions, packageResolveFrom) {
|
|
1169
1237
|
if (vuetifyOptions.icons === false) {
|
|
1170
1238
|
return disabledResolvedIcons;
|
|
1171
1239
|
}
|
|
@@ -1209,7 +1277,7 @@ function prepareIcons(unocssPresent, logger, vuetifyOptions) {
|
|
|
1209
1277
|
}
|
|
1210
1278
|
resolvedIcons.imports.push(`import {${name === defaultSet ? "aliases," : ""}${name}} from 'vuetify/iconsets/${name}'`);
|
|
1211
1279
|
resolvedIcons.sets.push(name);
|
|
1212
|
-
if (isPackageExists(iconsPackageNames[name].name)) {
|
|
1280
|
+
if (isPackageExists(iconsPackageNames[name].name, packageResolveFrom)) {
|
|
1213
1281
|
resolvedIcons.local.push(iconsPackageNames[name].css);
|
|
1214
1282
|
} else {
|
|
1215
1283
|
resolvedIcons.cdn.push([name, cdn ?? iconsCDN[name]]);
|
|
@@ -1228,18 +1296,21 @@ function prepareIcons(unocssPresent, logger, vuetifyOptions) {
|
|
|
1228
1296
|
if (!faSvg) {
|
|
1229
1297
|
faSvg = {};
|
|
1230
1298
|
}
|
|
1231
|
-
let faSvgExists = isPackageExists("@fortawesome/fontawesome-svg-core");
|
|
1299
|
+
let faSvgExists = isPackageExists("@fortawesome/fontawesome-svg-core", packageResolveFrom);
|
|
1232
1300
|
if (!faSvgExists) {
|
|
1233
1301
|
logger.warn("Missing @fortawesome/fontawesome-svg-core dependency, install it!");
|
|
1234
1302
|
}
|
|
1235
|
-
faSvgExists = isPackageExists("@fortawesome/vue-fontawesome");
|
|
1303
|
+
faSvgExists = isPackageExists("@fortawesome/vue-fontawesome", packageResolveFrom);
|
|
1236
1304
|
if (faSvgExists) {
|
|
1237
1305
|
if (!faSvg.libraries?.length) {
|
|
1238
1306
|
faSvg.libraries = [[false, "fas", "@fortawesome/free-solid-svg-icons"]];
|
|
1239
1307
|
}
|
|
1240
|
-
for (const
|
|
1241
|
-
|
|
1242
|
-
|
|
1308
|
+
for (const libraryEntry of faSvg.libraries) {
|
|
1309
|
+
if (!libraryEntry) {
|
|
1310
|
+
continue;
|
|
1311
|
+
}
|
|
1312
|
+
const library = libraryEntry[2];
|
|
1313
|
+
if (!isPackageExists(library, packageResolveFrom)) {
|
|
1243
1314
|
faSvgExists = false;
|
|
1244
1315
|
logger.warn(`Missing library ${library} dependency, install it!`);
|
|
1245
1316
|
}
|
|
@@ -1251,7 +1322,11 @@ function prepareIcons(unocssPresent, logger, vuetifyOptions) {
|
|
|
1251
1322
|
resolvedIcons.aliasesImportPresent ||= defaultSet === "fa-svg";
|
|
1252
1323
|
resolvedIcons.imports.push(`import {${defaultSet === "fa-svg" ? "aliases," : ""}fa} from 'vuetify/iconsets/fa-svg'`, "import { library } from '@fortawesome/fontawesome-svg-core'", "import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome'", "import { useNuxtApp } from '#imports'");
|
|
1253
1324
|
resolvedIcons.svg.fa = ["useNuxtApp().vueApp.component('font-awesome-icon', FontAwesomeIcon)"];
|
|
1254
|
-
for (const
|
|
1325
|
+
for (const libraryEntry of faSvg.libraries ?? []) {
|
|
1326
|
+
if (!libraryEntry) {
|
|
1327
|
+
continue;
|
|
1328
|
+
}
|
|
1329
|
+
const [defaultExport, name, library] = libraryEntry;
|
|
1255
1330
|
resolvedIcons.imports.push(`import ${defaultExport ? name : `{${name}}`} from '${library}'`);
|
|
1256
1331
|
resolvedIcons.svg.fa.push(`library.add(${name})`);
|
|
1257
1332
|
}
|
|
@@ -1266,7 +1341,7 @@ function prepareIcons(unocssPresent, logger, vuetifyOptions) {
|
|
|
1266
1341
|
if (!mdiSvg) {
|
|
1267
1342
|
mdiSvg = {};
|
|
1268
1343
|
}
|
|
1269
|
-
const mdiSvgExists = isPackageExists("@mdi/js");
|
|
1344
|
+
const mdiSvgExists = isPackageExists("@mdi/js", packageResolveFrom);
|
|
1270
1345
|
if (mdiSvgExists) {
|
|
1271
1346
|
resolvedIcons.svg.mdi = true;
|
|
1272
1347
|
resolvedIcons.aliasesImportPresent ||= defaultSet === "mdi-svg";
|
|
@@ -1314,7 +1389,7 @@ async function loadVuetifyConfiguration(cwd = process.cwd(), configOrPath = cwd,
|
|
|
1314
1389
|
inlineConfig = configOrPath;
|
|
1315
1390
|
configOrPath = process.cwd();
|
|
1316
1391
|
}
|
|
1317
|
-
const resolved = resolve
|
|
1392
|
+
const resolved = resolve(cwd, configOrPath);
|
|
1318
1393
|
let isFile = false;
|
|
1319
1394
|
if (existsSync(resolved) && statSync(resolved).isFile()) {
|
|
1320
1395
|
isFile = true;
|
|
@@ -1513,11 +1588,12 @@ async function prepareVuetifyStyles(nuxt, ctx) {
|
|
|
1513
1588
|
if (stylesConfig.experimental?.cache === false) {
|
|
1514
1589
|
return;
|
|
1515
1590
|
}
|
|
1516
|
-
const vuetifyBase = resolveVuetifyBase();
|
|
1591
|
+
const vuetifyBase = await resolveVuetifyBase();
|
|
1517
1592
|
let configFile;
|
|
1518
1593
|
let configContent = "";
|
|
1519
1594
|
if (stylesConfig.configFile) {
|
|
1520
|
-
configFile = await resolvePath(stylesConfig.configFile);
|
|
1595
|
+
configFile = await resolvePath(resolveVuetifyConfigFile(stylesConfig.configFile, nuxt));
|
|
1596
|
+
ctx.stylesConfigFile = configFile;
|
|
1521
1597
|
if (existsSync(configFile)) {
|
|
1522
1598
|
configContent = readFileSync(configFile, "utf8");
|
|
1523
1599
|
if (!ctx.vuetifyFilesToWatch.includes(configFile)) {
|
|
@@ -1528,18 +1604,15 @@ async function prepareVuetifyStyles(nuxt, ctx) {
|
|
|
1528
1604
|
if (!configFile) {
|
|
1529
1605
|
return;
|
|
1530
1606
|
}
|
|
1531
|
-
const hash =
|
|
1532
|
-
|
|
1533
|
-
|
|
1607
|
+
const hash = createStylesCacheHash(
|
|
1608
|
+
ctx.vuetifyVersion,
|
|
1609
|
+
ctx.viteVersion,
|
|
1610
|
+
configContent,
|
|
1611
|
+
configFile
|
|
1612
|
+
);
|
|
1613
|
+
const { stylesDir, cacheDir } = resolveStylesCachePaths(nuxt.options.rootDir, hash);
|
|
1534
1614
|
ctx.stylesCachePath = cacheDir;
|
|
1535
|
-
|
|
1536
|
-
const dirents = readdirSync(stylesDir, { withFileTypes: true });
|
|
1537
|
-
for (const dirent of dirents) {
|
|
1538
|
-
if (dirent.isDirectory() && dirent.name !== hash) {
|
|
1539
|
-
rmSync(join(stylesDir, dirent.name), { recursive: true, force: true });
|
|
1540
|
-
}
|
|
1541
|
-
}
|
|
1542
|
-
}
|
|
1615
|
+
cleanupOldStylesCaches(stylesDir, hash);
|
|
1543
1616
|
if (existsSync(cacheDir)) {
|
|
1544
1617
|
return;
|
|
1545
1618
|
}
|
|
@@ -1555,11 +1628,9 @@ async function prepareVuetifyStyles(nuxt, ctx) {
|
|
|
1555
1628
|
return;
|
|
1556
1629
|
}
|
|
1557
1630
|
}
|
|
1558
|
-
const files =
|
|
1559
|
-
findCssFiles(join(vuetifyBase, "lib/components"), files);
|
|
1560
|
-
findCssFiles(join(vuetifyBase, "lib/styles"), files);
|
|
1631
|
+
const files = collectVuetifyCssFiles(vuetifyBase);
|
|
1561
1632
|
for (const file of files) {
|
|
1562
|
-
const relativePath = relative
|
|
1633
|
+
const relativePath = relative(vuetifyBase, file);
|
|
1563
1634
|
const cacheFile = join(cacheDir, relativePath);
|
|
1564
1635
|
const sassFile = file.replace(/\.css$/, ".sass");
|
|
1565
1636
|
const scssFile = file.replace(/\.css$/, ".scss");
|
|
@@ -1582,8 +1653,8 @@ async function prepareVuetifyStyles(nuxt, ctx) {
|
|
|
1582
1653
|
loadPaths: [
|
|
1583
1654
|
dirname(configFile),
|
|
1584
1655
|
dirname(targetFile),
|
|
1585
|
-
resolve
|
|
1586
|
-
resolve
|
|
1656
|
+
resolve(vuetifyBase, ".."),
|
|
1657
|
+
resolve(vuetifyBase, "../.."),
|
|
1587
1658
|
// In case of monorepo/hoisting issues, but standard is enough
|
|
1588
1659
|
vuetifyBase
|
|
1589
1660
|
],
|
|
@@ -1604,24 +1675,6 @@ async function prepareVuetifyStyles(nuxt, ctx) {
|
|
|
1604
1675
|
};
|
|
1605
1676
|
writeFileSync(join(cacheDir, "metadata.json"), JSON.stringify(metadata, null, 2), "utf8");
|
|
1606
1677
|
}
|
|
1607
|
-
function findCssFiles(dir, fileList = []) {
|
|
1608
|
-
if (!existsSync(dir)) {
|
|
1609
|
-
return fileList;
|
|
1610
|
-
}
|
|
1611
|
-
const files = readdirSync(dir);
|
|
1612
|
-
for (const file of files) {
|
|
1613
|
-
const filePath = join(dir, file);
|
|
1614
|
-
const stat = statSync(filePath);
|
|
1615
|
-
if (stat.isDirectory()) {
|
|
1616
|
-
findCssFiles(filePath, fileList);
|
|
1617
|
-
} else {
|
|
1618
|
-
if (file.endsWith(".css")) {
|
|
1619
|
-
fileList.push(filePath);
|
|
1620
|
-
}
|
|
1621
|
-
}
|
|
1622
|
-
}
|
|
1623
|
-
return fileList;
|
|
1624
|
-
}
|
|
1625
1678
|
|
|
1626
1679
|
async function load(options, nuxt, ctx) {
|
|
1627
1680
|
const {
|
|
@@ -1648,7 +1701,7 @@ async function load(options, nuxt, ctx) {
|
|
|
1648
1701
|
const dateOptions = vuetifyOptions.date;
|
|
1649
1702
|
if (dateOptions) {
|
|
1650
1703
|
const adapter = dateOptions.adapter;
|
|
1651
|
-
const date = detectDate();
|
|
1704
|
+
const date = detectDate(ctx.packageResolveFrom);
|
|
1652
1705
|
if (!adapter && date.length > 1) {
|
|
1653
1706
|
throw new Error(`Multiple date adapters found: ${date.map((d) => `@date-io/${d[0]}`).join(", ")}, please specify the adapter to use in the "vuetifyOptions.date.adapter" option.`);
|
|
1654
1707
|
}
|
|
@@ -1677,7 +1730,7 @@ async function load(options, nuxt, ctx) {
|
|
|
1677
1730
|
ctx.enableRules = ctx.moduleOptions.enableRules;
|
|
1678
1731
|
ctx.rulesConfiguration = ctx.moduleOptions.rulesConfiguration;
|
|
1679
1732
|
ctx.vuetifyFilesToWatch = Array.from(vuetifyConfigurationFilesToWatch);
|
|
1680
|
-
ctx.icons = prepareIcons(ctx.unocss, ctx.logger, vuetifyAppOptions);
|
|
1733
|
+
ctx.icons = prepareIcons(ctx.unocss, ctx.logger, vuetifyAppOptions, ctx.packageResolveFrom);
|
|
1681
1734
|
ctx.ssrClientHints = prepareSSRClientHints(nuxt.options.app.baseURL ?? "/", ctx);
|
|
1682
1735
|
if (ctx.icons.enabled) {
|
|
1683
1736
|
if (ctx.icons.local) {
|
|
@@ -1704,7 +1757,7 @@ function registerWatcher(options, nuxt, ctx) {
|
|
|
1704
1757
|
if (nuxt.options.dev) {
|
|
1705
1758
|
let pageReload;
|
|
1706
1759
|
nuxt.hooks.hook("builder:watch", (_event, path) => {
|
|
1707
|
-
path = relative
|
|
1760
|
+
path = relative(nuxt.options.srcDir, resolve(nuxt.options.srcDir, path));
|
|
1708
1761
|
if (!pageReload && ctx.vuetifyFilesToWatch.includes(path)) {
|
|
1709
1762
|
return nuxt.callHook("restart");
|
|
1710
1763
|
}
|
|
@@ -1778,13 +1831,16 @@ const module$1 = defineNuxtModule({
|
|
|
1778
1831
|
if (isNuxtMajorVersion(2, nuxt)) {
|
|
1779
1832
|
logger.error(`Cannot support nuxt version: ${getNuxtVersion(nuxt)}`);
|
|
1780
1833
|
}
|
|
1781
|
-
const
|
|
1834
|
+
const resolver = createResolver(import.meta.url);
|
|
1835
|
+
const packageResolveFrom = pathToFileURL(resolver.resolve(nuxt.options.rootDir, "package.json")).href;
|
|
1836
|
+
const vuetifyPkg = await loadPackageJSON("vuetify", packageResolveFrom);
|
|
1782
1837
|
const currentVersion = vuetifyPkg?.version;
|
|
1783
1838
|
const vuetifyGte = (version2) => !!currentVersion && semver.gte(currentVersion, version2);
|
|
1784
1839
|
const viteVersion = version$1;
|
|
1785
1840
|
const ctx = {
|
|
1786
1841
|
logger,
|
|
1787
|
-
resolver
|
|
1842
|
+
resolver,
|
|
1843
|
+
packageResolveFrom,
|
|
1788
1844
|
moduleOptions: void 0,
|
|
1789
1845
|
vuetifyOptions: void 0,
|
|
1790
1846
|
vuetifyFilesToWatch: [],
|
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-beta.
|
|
4
|
+
"version": "1.0.0-beta.3",
|
|
5
5
|
"description": "Zero-Config Nuxt Module for Vuetify",
|
|
6
6
|
"author": "userquin <userquin@gmail.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -54,7 +54,6 @@
|
|
|
54
54
|
"@nuxt/kit": "^4.3.1",
|
|
55
55
|
"defu": "^6.1.4",
|
|
56
56
|
"destr": "^2.0.5",
|
|
57
|
-
"local-pkg": "^1.1.2",
|
|
58
57
|
"pathe": "^2.0.3",
|
|
59
58
|
"perfect-debounce": "^2.1.0",
|
|
60
59
|
"semver": "^7.7.4",
|
|
@@ -103,7 +102,6 @@
|
|
|
103
102
|
"consola",
|
|
104
103
|
"destr",
|
|
105
104
|
"esbuild",
|
|
106
|
-
"local-pkg",
|
|
107
105
|
"pathe",
|
|
108
106
|
"perfect-debounce",
|
|
109
107
|
"rollup",
|