vuetify-nuxt-module 1.0.0-beta.3 → 1.0.0-beta.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/dist/module.d.mts +12 -0
- package/dist/module.json +1 -1
- package/dist/module.mjs +40 -317
- package/package.json +9 -5
package/dist/module.d.mts
CHANGED
|
@@ -251,6 +251,18 @@ interface MOptions {
|
|
|
251
251
|
* Path to the custom Vuetify SASS configuration file.
|
|
252
252
|
*/
|
|
253
253
|
configFile: string;
|
|
254
|
+
/**
|
|
255
|
+
* Caching options forwarded to `@vuetify/unplugin-styles`.
|
|
256
|
+
*
|
|
257
|
+
* @default true
|
|
258
|
+
*/
|
|
259
|
+
cache?: boolean | {
|
|
260
|
+
path?: string;
|
|
261
|
+
sassOptions?: Record<string, unknown>;
|
|
262
|
+
};
|
|
263
|
+
/**
|
|
264
|
+
* @deprecated Use `styles.cache` instead.
|
|
265
|
+
*/
|
|
254
266
|
experimental?: {
|
|
255
267
|
cache?: boolean;
|
|
256
268
|
};
|
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { addPluginTemplate, resolvePath, addTemplate, extendWebpackConfig, isNuxtMajorVersion, addImports, addPlugin, addVitePlugin, useLogger, defineNuxtModule, getNuxtVersion, hasNuxtModule, createResolver } from '@nuxt/kit';
|
|
2
|
+
import { isPackageExists, getPackageInfo } from 'local-pkg';
|
|
3
3
|
import semver from 'semver';
|
|
4
4
|
import { createFilter, version as version$1 } from 'vite';
|
|
5
5
|
import defu from 'defu';
|
|
6
6
|
import { transformAssetUrls } from 'vite-plugin-vuetify';
|
|
7
|
-
import {
|
|
8
|
-
import
|
|
9
|
-
import {
|
|
10
|
-
import
|
|
7
|
+
import { existsSync, statSync } from 'node:fs';
|
|
8
|
+
import { isAbsolute, resolve, dirname, relative } from 'pathe';
|
|
9
|
+
import { generateImports, resolveVuetifyBase, isObject } from '@vuetify/loader-shared';
|
|
10
|
+
import Styles from '@vuetify/unplugin-styles/vite';
|
|
11
|
+
import { pathToFileURL } from 'node:url';
|
|
11
12
|
import destr from 'destr';
|
|
12
13
|
import { parseQuery, parseURL } from 'ufo';
|
|
13
|
-
import
|
|
14
|
-
import path from 'upath';
|
|
14
|
+
import { readFile } from 'node:fs/promises';
|
|
15
15
|
import { debounce } from 'perfect-debounce';
|
|
16
16
|
import process from 'node:process';
|
|
17
17
|
import { createConfigLoader } from 'unconfig';
|
|
18
18
|
|
|
19
|
-
const version = "1.0.0-beta.
|
|
19
|
+
const version = "1.0.0-beta.5";
|
|
20
20
|
|
|
21
21
|
const VIRTUAL_VUETIFY_CONFIGURATION = "virtual:vuetify-configuration";
|
|
22
22
|
const RESOLVED_VIRTUAL_VUETIFY_CONFIGURATION = `\0${VIRTUAL_VUETIFY_CONFIGURATION}`;
|
|
@@ -137,52 +137,6 @@ function resolveVuetifyConfigFile(configFile, nuxt) {
|
|
|
137
137
|
}
|
|
138
138
|
return configFile;
|
|
139
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
140
|
|
|
187
141
|
function addVuetifyNuxtPlugins(nuxt, ctx) {
|
|
188
142
|
addVuetifyNuxtPlugin(nuxt, ctx, "client");
|
|
@@ -947,144 +901,7 @@ function vuetifySSRClientHintsPlugin(ctx) {
|
|
|
947
901
|
};
|
|
948
902
|
}
|
|
949
903
|
|
|
950
|
-
function
|
|
951
|
-
let configFile;
|
|
952
|
-
let vuetifyBase;
|
|
953
|
-
const options = { styles: ctx.moduleOptions.styles };
|
|
954
|
-
const noneFiles = /* @__PURE__ */ new Set();
|
|
955
|
-
let isNone = false;
|
|
956
|
-
let sassVariables = false;
|
|
957
|
-
let fileImport = false;
|
|
958
|
-
const PREFIX = "vuetify-styles/";
|
|
959
|
-
const SSR_PREFIX = `/@${PREFIX}`;
|
|
960
|
-
const resolveCss = resolveCssFactory();
|
|
961
|
-
const toPath = (file) => fileImport ? pathToFileURL(file).href : normalizePath(file);
|
|
962
|
-
return {
|
|
963
|
-
name: "vuetify:styles:nuxt",
|
|
964
|
-
enforce: "pre",
|
|
965
|
-
async configResolved(config) {
|
|
966
|
-
if (config.plugins.some((plugin) => plugin.name === "vuetify:styles")) {
|
|
967
|
-
throw new Error("Remove vite-plugin-vuetify from your Nuxt config file, this module registers a modified version.");
|
|
968
|
-
}
|
|
969
|
-
if (isObject(options.styles) && "configFile" in options.styles) {
|
|
970
|
-
sassVariables = true;
|
|
971
|
-
fileImport = semver.gt(ctx.viteVersion, "5.4.2");
|
|
972
|
-
configFile = ctx.stylesConfigFile ?? await resolvePath(options.styles.configFile);
|
|
973
|
-
} else {
|
|
974
|
-
isNone = options.styles === "none";
|
|
975
|
-
}
|
|
976
|
-
vuetifyBase = await resolveVuetifyBase();
|
|
977
|
-
},
|
|
978
|
-
async resolveId(source, importer, { custom, ssr }) {
|
|
979
|
-
if (!sassVariables) {
|
|
980
|
-
return;
|
|
981
|
-
}
|
|
982
|
-
if (source.startsWith(PREFIX) || source.startsWith(SSR_PREFIX)) {
|
|
983
|
-
if (/\.s[ca]ss$/.test(source)) {
|
|
984
|
-
return source;
|
|
985
|
-
}
|
|
986
|
-
const idx = source.indexOf("?");
|
|
987
|
-
return idx === -1 ? source : source.slice(0, idx);
|
|
988
|
-
}
|
|
989
|
-
if (vuetifyBase && importer && source.endsWith(".css") && isSubdir(vuetifyBase, path.isAbsolute(source) ? source : importer)) {
|
|
990
|
-
let resolutionId;
|
|
991
|
-
if (source.startsWith(".")) {
|
|
992
|
-
resolutionId = path.resolve(path.dirname(importer), source);
|
|
993
|
-
} else if (path.isAbsolute(source)) {
|
|
994
|
-
resolutionId = source;
|
|
995
|
-
} else {
|
|
996
|
-
const resolution = await this.resolve(source, importer, { skipSelf: true, custom });
|
|
997
|
-
if (resolution) {
|
|
998
|
-
resolutionId = resolution.id;
|
|
999
|
-
}
|
|
1000
|
-
}
|
|
1001
|
-
if (!resolutionId) {
|
|
1002
|
-
return;
|
|
1003
|
-
}
|
|
1004
|
-
const target = await resolveCss(resolutionId);
|
|
1005
|
-
if (isNone) {
|
|
1006
|
-
noneFiles.add(target);
|
|
1007
|
-
return target;
|
|
1008
|
-
}
|
|
1009
|
-
if (ctx.stylesCachePath) {
|
|
1010
|
-
const relative = path.relative(vuetifyBase, target);
|
|
1011
|
-
const cacheFile = path.resolve(ctx.stylesCachePath, relative.replace(/\.s[ac]ss$/, ".css"));
|
|
1012
|
-
if (fs.existsSync(cacheFile)) {
|
|
1013
|
-
return cacheFile;
|
|
1014
|
-
}
|
|
1015
|
-
}
|
|
1016
|
-
return `${ssr ? SSR_PREFIX : PREFIX}${path.relative(vuetifyBase, target)}`;
|
|
1017
|
-
}
|
|
1018
|
-
return void 0;
|
|
1019
|
-
},
|
|
1020
|
-
load(id) {
|
|
1021
|
-
if (sassVariables) {
|
|
1022
|
-
if (!vuetifyBase) {
|
|
1023
|
-
return;
|
|
1024
|
-
}
|
|
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;
|
|
1026
|
-
if (target) {
|
|
1027
|
-
const suffix = /\.scss/.test(target) ? ";\n" : "\n";
|
|
1028
|
-
return {
|
|
1029
|
-
code: `@use "${toPath(configFile)}"${suffix}@use "${toPath(target)}"${suffix}`,
|
|
1030
|
-
map: {
|
|
1031
|
-
mappings: ""
|
|
1032
|
-
}
|
|
1033
|
-
};
|
|
1034
|
-
}
|
|
1035
|
-
}
|
|
1036
|
-
return isNone && noneFiles.has(id) ? "" : void 0;
|
|
1037
|
-
}
|
|
1038
|
-
};
|
|
1039
|
-
}
|
|
1040
|
-
function resolveCssFactory() {
|
|
1041
|
-
const mappings = /* @__PURE__ */ new Map();
|
|
1042
|
-
return async (source) => {
|
|
1043
|
-
let mapping = mappings.get(source);
|
|
1044
|
-
if (!mapping) {
|
|
1045
|
-
try {
|
|
1046
|
-
mapping = source.replace(/\.css$/, ".sass");
|
|
1047
|
-
await fsp.access(mapping, fs.constants.R_OK);
|
|
1048
|
-
} catch (error) {
|
|
1049
|
-
if (!(error instanceof Error && "code" in error && error.code === "ENOENT")) {
|
|
1050
|
-
throw error;
|
|
1051
|
-
}
|
|
1052
|
-
try {
|
|
1053
|
-
mapping = source.replace(/\.css$/, ".scss");
|
|
1054
|
-
await fsp.access(mapping, fs.constants.R_OK);
|
|
1055
|
-
} catch {
|
|
1056
|
-
mapping = source;
|
|
1057
|
-
}
|
|
1058
|
-
}
|
|
1059
|
-
mappings.set(source, mapping);
|
|
1060
|
-
}
|
|
1061
|
-
return mapping;
|
|
1062
|
-
};
|
|
1063
|
-
}
|
|
1064
|
-
function isSubdir(root, test) {
|
|
1065
|
-
const relative$1 = relative(root, test);
|
|
1066
|
-
return relative$1 && !relative$1.startsWith("..") && !isAbsolute(relative$1);
|
|
1067
|
-
}
|
|
1068
|
-
|
|
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) {
|
|
904
|
+
function detectDate() {
|
|
1088
905
|
const result = [];
|
|
1089
906
|
for (const adapter of [
|
|
1090
907
|
"date-fns",
|
|
@@ -1096,7 +913,7 @@ function detectDate(packageResolveFrom) {
|
|
|
1096
913
|
"jalaali",
|
|
1097
914
|
"hijri"
|
|
1098
915
|
]) {
|
|
1099
|
-
if (isPackageExists(`@date-io/${adapter}
|
|
916
|
+
if (isPackageExists(`@date-io/${adapter}`)) {
|
|
1100
917
|
result.push(adapter);
|
|
1101
918
|
}
|
|
1102
919
|
}
|
|
@@ -1141,6 +958,9 @@ function resolveVuetifyComponents(resolver) {
|
|
|
1141
958
|
}
|
|
1142
959
|
}
|
|
1143
960
|
|
|
961
|
+
function resolveStylesCache(stylesOption) {
|
|
962
|
+
return stylesOption.cache ?? stylesOption.experimental?.cache;
|
|
963
|
+
}
|
|
1144
964
|
function configureVite(configKey, nuxt, ctx) {
|
|
1145
965
|
nuxt.hook("vite:extend", ({ config }) => checkVuetifyPlugins(config));
|
|
1146
966
|
nuxt.hook("vite:extendConfig", (viteInlineConfig) => {
|
|
@@ -1149,7 +969,7 @@ function configureVite(configKey, nuxt, ctx) {
|
|
|
1149
969
|
if (!ctx.moduleOptions.disableModernSassCompiler) {
|
|
1150
970
|
const enableModernSassCompiler = semver.gte(ctx.viteVersion, "5.4.0") && semver.lt(ctx.viteVersion, "7.0.0-0");
|
|
1151
971
|
if (enableModernSassCompiler) {
|
|
1152
|
-
const sassEmbedded = isPackageExists("sass-embedded"
|
|
972
|
+
const sassEmbedded = isPackageExists("sass-embedded");
|
|
1153
973
|
if (sassEmbedded) {
|
|
1154
974
|
viteInlineConfig.css ??= {};
|
|
1155
975
|
viteInlineConfig.css.preprocessorOptions ??= {};
|
|
@@ -1193,8 +1013,18 @@ function configureVite(configKey, nuxt, ctx) {
|
|
|
1193
1013
|
autoImport.ignore = Array.isArray(ignoreDirectives) ? ignoreDirectives : [ignoreDirectives];
|
|
1194
1014
|
}
|
|
1195
1015
|
viteInlineConfig.plugins.push(vuetifyImportPlugin({ autoImport }));
|
|
1196
|
-
|
|
1197
|
-
|
|
1016
|
+
const stylesOption = ctx.moduleOptions.styles;
|
|
1017
|
+
if (stylesOption === "none") {
|
|
1018
|
+
viteInlineConfig.plugins.push(Styles({ styles: "none" }));
|
|
1019
|
+
} else if (isObject(stylesOption) && "configFile" in stylesOption) {
|
|
1020
|
+
if (!ctx.stylesConfigFile) {
|
|
1021
|
+
throw new Error("vuetify-nuxt-module: styles.configFile could not be resolved");
|
|
1022
|
+
}
|
|
1023
|
+
const cache = resolveStylesCache(stylesOption);
|
|
1024
|
+
viteInlineConfig.plugins.push(Styles({
|
|
1025
|
+
settings: ctx.stylesConfigFile,
|
|
1026
|
+
...cache === void 0 ? {} : { cache }
|
|
1027
|
+
}));
|
|
1198
1028
|
}
|
|
1199
1029
|
viteInlineConfig.plugins.push(vuetifyConfigurationPlugin(ctx), vuetifyIconsPlugin(ctx), vuetifyDateConfigurationPlugin(ctx));
|
|
1200
1030
|
if (ctx.ssrClientHints.enabled) {
|
|
@@ -1233,7 +1063,7 @@ const disabledResolvedIcons = Object.freeze({
|
|
|
1233
1063
|
local: [],
|
|
1234
1064
|
svg: {}
|
|
1235
1065
|
});
|
|
1236
|
-
function prepareIcons(unocssPresent, logger, vuetifyOptions
|
|
1066
|
+
function prepareIcons(unocssPresent, logger, vuetifyOptions) {
|
|
1237
1067
|
if (vuetifyOptions.icons === false) {
|
|
1238
1068
|
return disabledResolvedIcons;
|
|
1239
1069
|
}
|
|
@@ -1277,7 +1107,7 @@ function prepareIcons(unocssPresent, logger, vuetifyOptions, packageResolveFrom)
|
|
|
1277
1107
|
}
|
|
1278
1108
|
resolvedIcons.imports.push(`import {${name === defaultSet ? "aliases," : ""}${name}} from 'vuetify/iconsets/${name}'`);
|
|
1279
1109
|
resolvedIcons.sets.push(name);
|
|
1280
|
-
if (isPackageExists(iconsPackageNames[name].name
|
|
1110
|
+
if (isPackageExists(iconsPackageNames[name].name)) {
|
|
1281
1111
|
resolvedIcons.local.push(iconsPackageNames[name].css);
|
|
1282
1112
|
} else {
|
|
1283
1113
|
resolvedIcons.cdn.push([name, cdn ?? iconsCDN[name]]);
|
|
@@ -1296,21 +1126,18 @@ function prepareIcons(unocssPresent, logger, vuetifyOptions, packageResolveFrom)
|
|
|
1296
1126
|
if (!faSvg) {
|
|
1297
1127
|
faSvg = {};
|
|
1298
1128
|
}
|
|
1299
|
-
let faSvgExists = isPackageExists("@fortawesome/fontawesome-svg-core"
|
|
1129
|
+
let faSvgExists = isPackageExists("@fortawesome/fontawesome-svg-core");
|
|
1300
1130
|
if (!faSvgExists) {
|
|
1301
1131
|
logger.warn("Missing @fortawesome/fontawesome-svg-core dependency, install it!");
|
|
1302
1132
|
}
|
|
1303
|
-
faSvgExists = isPackageExists("@fortawesome/vue-fontawesome"
|
|
1133
|
+
faSvgExists = isPackageExists("@fortawesome/vue-fontawesome");
|
|
1304
1134
|
if (faSvgExists) {
|
|
1305
1135
|
if (!faSvg.libraries?.length) {
|
|
1306
1136
|
faSvg.libraries = [[false, "fas", "@fortawesome/free-solid-svg-icons"]];
|
|
1307
1137
|
}
|
|
1308
|
-
for (const
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
}
|
|
1312
|
-
const library = libraryEntry[2];
|
|
1313
|
-
if (!isPackageExists(library, packageResolveFrom)) {
|
|
1138
|
+
for (const p in faSvg.libraries) {
|
|
1139
|
+
const [_defaultExport, _name, library] = faSvg.libraries[p];
|
|
1140
|
+
if (!isPackageExists(library)) {
|
|
1314
1141
|
faSvgExists = false;
|
|
1315
1142
|
logger.warn(`Missing library ${library} dependency, install it!`);
|
|
1316
1143
|
}
|
|
@@ -1322,11 +1149,7 @@ function prepareIcons(unocssPresent, logger, vuetifyOptions, packageResolveFrom)
|
|
|
1322
1149
|
resolvedIcons.aliasesImportPresent ||= defaultSet === "fa-svg";
|
|
1323
1150
|
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'");
|
|
1324
1151
|
resolvedIcons.svg.fa = ["useNuxtApp().vueApp.component('font-awesome-icon', FontAwesomeIcon)"];
|
|
1325
|
-
for (const
|
|
1326
|
-
if (!libraryEntry) {
|
|
1327
|
-
continue;
|
|
1328
|
-
}
|
|
1329
|
-
const [defaultExport, name, library] = libraryEntry;
|
|
1152
|
+
for (const [defaultExport, name, library] of faSvg.libraries) {
|
|
1330
1153
|
resolvedIcons.imports.push(`import ${defaultExport ? name : `{${name}}`} from '${library}'`);
|
|
1331
1154
|
resolvedIcons.svg.fa.push(`library.add(${name})`);
|
|
1332
1155
|
}
|
|
@@ -1341,7 +1164,7 @@ function prepareIcons(unocssPresent, logger, vuetifyOptions, packageResolveFrom)
|
|
|
1341
1164
|
if (!mdiSvg) {
|
|
1342
1165
|
mdiSvg = {};
|
|
1343
1166
|
}
|
|
1344
|
-
const mdiSvgExists = isPackageExists("@mdi/js"
|
|
1167
|
+
const mdiSvgExists = isPackageExists("@mdi/js");
|
|
1345
1168
|
if (mdiSvgExists) {
|
|
1346
1169
|
resolvedIcons.svg.mdi = true;
|
|
1347
1170
|
resolvedIcons.aliasesImportPresent ||= defaultSet === "mdi-svg";
|
|
@@ -1580,102 +1403,6 @@ function prepareSSRClientHints(baseUrl, ctx) {
|
|
|
1580
1403
|
return clientHints;
|
|
1581
1404
|
}
|
|
1582
1405
|
|
|
1583
|
-
async function prepareVuetifyStyles(nuxt, ctx) {
|
|
1584
|
-
const stylesConfig = ctx.moduleOptions.styles;
|
|
1585
|
-
if (!isObject(stylesConfig) || !("configFile" in stylesConfig)) {
|
|
1586
|
-
return;
|
|
1587
|
-
}
|
|
1588
|
-
if (stylesConfig.experimental?.cache === false) {
|
|
1589
|
-
return;
|
|
1590
|
-
}
|
|
1591
|
-
const vuetifyBase = await resolveVuetifyBase();
|
|
1592
|
-
let configFile;
|
|
1593
|
-
let configContent = "";
|
|
1594
|
-
if (stylesConfig.configFile) {
|
|
1595
|
-
configFile = await resolvePath(resolveVuetifyConfigFile(stylesConfig.configFile, nuxt));
|
|
1596
|
-
ctx.stylesConfigFile = configFile;
|
|
1597
|
-
if (existsSync(configFile)) {
|
|
1598
|
-
configContent = readFileSync(configFile, "utf8");
|
|
1599
|
-
if (!ctx.vuetifyFilesToWatch.includes(configFile)) {
|
|
1600
|
-
ctx.vuetifyFilesToWatch.push(configFile);
|
|
1601
|
-
}
|
|
1602
|
-
}
|
|
1603
|
-
}
|
|
1604
|
-
if (!configFile) {
|
|
1605
|
-
return;
|
|
1606
|
-
}
|
|
1607
|
-
const hash = createStylesCacheHash(
|
|
1608
|
-
ctx.vuetifyVersion,
|
|
1609
|
-
ctx.viteVersion,
|
|
1610
|
-
configContent,
|
|
1611
|
-
configFile
|
|
1612
|
-
);
|
|
1613
|
-
const { stylesDir, cacheDir } = resolveStylesCachePaths(nuxt.options.rootDir, hash);
|
|
1614
|
-
ctx.stylesCachePath = cacheDir;
|
|
1615
|
-
cleanupOldStylesCaches(stylesDir, hash);
|
|
1616
|
-
if (existsSync(cacheDir)) {
|
|
1617
|
-
return;
|
|
1618
|
-
}
|
|
1619
|
-
ctx.logger.info("Compiling Vuetify styles...");
|
|
1620
|
-
let sass;
|
|
1621
|
-
try {
|
|
1622
|
-
sass = await import('sass');
|
|
1623
|
-
} catch {
|
|
1624
|
-
try {
|
|
1625
|
-
sass = await import('sass-embedded');
|
|
1626
|
-
} catch {
|
|
1627
|
-
ctx.logger.warn('Could not load "sass" or "sass-embedded". Skipping styles pre-compilation.');
|
|
1628
|
-
return;
|
|
1629
|
-
}
|
|
1630
|
-
}
|
|
1631
|
-
const files = collectVuetifyCssFiles(vuetifyBase);
|
|
1632
|
-
for (const file of files) {
|
|
1633
|
-
const relativePath = relative(vuetifyBase, file);
|
|
1634
|
-
const cacheFile = join(cacheDir, relativePath);
|
|
1635
|
-
const sassFile = file.replace(/\.css$/, ".sass");
|
|
1636
|
-
const scssFile = file.replace(/\.css$/, ".scss");
|
|
1637
|
-
let targetFile;
|
|
1638
|
-
if (existsSync(sassFile)) {
|
|
1639
|
-
targetFile = sassFile;
|
|
1640
|
-
} else if (existsSync(scssFile)) {
|
|
1641
|
-
targetFile = scssFile;
|
|
1642
|
-
}
|
|
1643
|
-
if (targetFile) {
|
|
1644
|
-
const dir = dirname(cacheFile);
|
|
1645
|
-
if (!existsSync(dir)) {
|
|
1646
|
-
mkdirSync(dir, { recursive: true });
|
|
1647
|
-
}
|
|
1648
|
-
const content = `@use "${normalizePath(configFile)}";
|
|
1649
|
-
@use "${normalizePath(targetFile)}";
|
|
1650
|
-
`;
|
|
1651
|
-
try {
|
|
1652
|
-
const result = sass.compileString(content, {
|
|
1653
|
-
loadPaths: [
|
|
1654
|
-
dirname(configFile),
|
|
1655
|
-
dirname(targetFile),
|
|
1656
|
-
resolve(vuetifyBase, ".."),
|
|
1657
|
-
resolve(vuetifyBase, "../.."),
|
|
1658
|
-
// In case of monorepo/hoisting issues, but standard is enough
|
|
1659
|
-
vuetifyBase
|
|
1660
|
-
],
|
|
1661
|
-
url: new URL(pathToFileURL(cacheFile).href)
|
|
1662
|
-
});
|
|
1663
|
-
writeFileSync(cacheFile, result.css, "utf8");
|
|
1664
|
-
} catch (error) {
|
|
1665
|
-
ctx.logger.error(`Failed to compile ${targetFile}:`, error);
|
|
1666
|
-
}
|
|
1667
|
-
}
|
|
1668
|
-
}
|
|
1669
|
-
const metadata = {
|
|
1670
|
-
hash,
|
|
1671
|
-
vuetifyVersion: ctx.vuetifyVersion,
|
|
1672
|
-
viteVersion: ctx.viteVersion,
|
|
1673
|
-
configFile,
|
|
1674
|
-
createdAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
1675
|
-
};
|
|
1676
|
-
writeFileSync(join(cacheDir, "metadata.json"), JSON.stringify(metadata, null, 2), "utf8");
|
|
1677
|
-
}
|
|
1678
|
-
|
|
1679
1406
|
async function load(options, nuxt, ctx) {
|
|
1680
1407
|
const {
|
|
1681
1408
|
configuration,
|
|
@@ -1701,7 +1428,7 @@ async function load(options, nuxt, ctx) {
|
|
|
1701
1428
|
const dateOptions = vuetifyOptions.date;
|
|
1702
1429
|
if (dateOptions) {
|
|
1703
1430
|
const adapter = dateOptions.adapter;
|
|
1704
|
-
const date = detectDate(
|
|
1431
|
+
const date = detectDate();
|
|
1705
1432
|
if (!adapter && date.length > 1) {
|
|
1706
1433
|
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.`);
|
|
1707
1434
|
}
|
|
@@ -1730,7 +1457,7 @@ async function load(options, nuxt, ctx) {
|
|
|
1730
1457
|
ctx.enableRules = ctx.moduleOptions.enableRules;
|
|
1731
1458
|
ctx.rulesConfiguration = ctx.moduleOptions.rulesConfiguration;
|
|
1732
1459
|
ctx.vuetifyFilesToWatch = Array.from(vuetifyConfigurationFilesToWatch);
|
|
1733
|
-
ctx.icons = prepareIcons(ctx.unocss, ctx.logger, vuetifyAppOptions
|
|
1460
|
+
ctx.icons = prepareIcons(ctx.unocss, ctx.logger, vuetifyAppOptions);
|
|
1734
1461
|
ctx.ssrClientHints = prepareSSRClientHints(nuxt.options.app.baseURL ?? "/", ctx);
|
|
1735
1462
|
if (ctx.icons.enabled) {
|
|
1736
1463
|
if (ctx.icons.local) {
|
|
@@ -1751,7 +1478,6 @@ async function load(options, nuxt, ctx) {
|
|
|
1751
1478
|
}
|
|
1752
1479
|
}
|
|
1753
1480
|
}
|
|
1754
|
-
await prepareVuetifyStyles(nuxt, ctx);
|
|
1755
1481
|
}
|
|
1756
1482
|
function registerWatcher(options, nuxt, ctx) {
|
|
1757
1483
|
if (nuxt.options.dev) {
|
|
@@ -1831,16 +1557,13 @@ const module$1 = defineNuxtModule({
|
|
|
1831
1557
|
if (isNuxtMajorVersion(2, nuxt)) {
|
|
1832
1558
|
logger.error(`Cannot support nuxt version: ${getNuxtVersion(nuxt)}`);
|
|
1833
1559
|
}
|
|
1834
|
-
const
|
|
1835
|
-
const packageResolveFrom = pathToFileURL(resolver.resolve(nuxt.options.rootDir, "package.json")).href;
|
|
1836
|
-
const vuetifyPkg = await loadPackageJSON("vuetify", packageResolveFrom);
|
|
1560
|
+
const vuetifyPkg = await getPackageInfo("vuetify");
|
|
1837
1561
|
const currentVersion = vuetifyPkg?.version;
|
|
1838
1562
|
const vuetifyGte = (version2) => !!currentVersion && semver.gte(currentVersion, version2);
|
|
1839
1563
|
const viteVersion = version$1;
|
|
1840
1564
|
const ctx = {
|
|
1841
1565
|
logger,
|
|
1842
|
-
resolver,
|
|
1843
|
-
packageResolveFrom,
|
|
1566
|
+
resolver: createResolver(import.meta.url),
|
|
1844
1567
|
moduleOptions: void 0,
|
|
1845
1568
|
vuetifyOptions: void 0,
|
|
1846
1569
|
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.5",
|
|
5
5
|
"description": "Zero-Config Nuxt Module for Vuetify",
|
|
6
6
|
"author": "userquin <userquin@gmail.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -52,14 +52,15 @@
|
|
|
52
52
|
],
|
|
53
53
|
"dependencies": {
|
|
54
54
|
"@nuxt/kit": "^4.3.1",
|
|
55
|
+
"@vuetify/unplugin-styles": "^1.0.0-beta.10",
|
|
55
56
|
"defu": "^6.1.4",
|
|
56
57
|
"destr": "^2.0.5",
|
|
58
|
+
"local-pkg": "^1.1.2",
|
|
57
59
|
"pathe": "^2.0.3",
|
|
58
60
|
"perfect-debounce": "^2.1.0",
|
|
59
61
|
"semver": "^7.7.4",
|
|
60
62
|
"ufo": "^1.6.3",
|
|
61
63
|
"unconfig": "^7.5.0",
|
|
62
|
-
"upath": "^2.0.1",
|
|
63
64
|
"vite-plugin-vuetify": "^2.1.3",
|
|
64
65
|
"vuetify": "^4.0.1"
|
|
65
66
|
},
|
|
@@ -86,6 +87,7 @@
|
|
|
86
87
|
"eslint": "^10.0.2",
|
|
87
88
|
"luxon": "^3.7.2",
|
|
88
89
|
"nuxt": "^4.3.1",
|
|
90
|
+
"playwright-core": "^1.58.0",
|
|
89
91
|
"publint": "^0.3.18",
|
|
90
92
|
"rimraf": "^6.1.3",
|
|
91
93
|
"sass": "^1.97.3",
|
|
@@ -97,17 +99,18 @@
|
|
|
97
99
|
"build": {
|
|
98
100
|
"externals": [
|
|
99
101
|
"@vuetify/loader-shared",
|
|
102
|
+
"@vuetify/unplugin-styles",
|
|
100
103
|
"node:child_process",
|
|
101
104
|
"node:fs",
|
|
102
105
|
"consola",
|
|
103
106
|
"destr",
|
|
104
107
|
"esbuild",
|
|
108
|
+
"local-pkg",
|
|
105
109
|
"pathe",
|
|
106
110
|
"perfect-debounce",
|
|
107
111
|
"rollup",
|
|
108
112
|
"sass",
|
|
109
113
|
"sass-embedded",
|
|
110
|
-
"upath",
|
|
111
114
|
"ufo",
|
|
112
115
|
"unconfig",
|
|
113
116
|
"vite",
|
|
@@ -137,8 +140,9 @@
|
|
|
137
140
|
"lint": "eslint .",
|
|
138
141
|
"lint:fix": "nr lint --fix",
|
|
139
142
|
"publint": "publint",
|
|
140
|
-
"test": "vitest run",
|
|
141
|
-
"test:watch": "vitest watch",
|
|
143
|
+
"test": "vitest run --exclude 'test/e2e/**'",
|
|
144
|
+
"test:watch": "vitest watch --exclude 'test/e2e/**'",
|
|
145
|
+
"test:e2e": "vitest run test/e2e",
|
|
142
146
|
"release": "bumpp"
|
|
143
147
|
}
|
|
144
148
|
}
|