@resee-movies/nuxt-ux 0.0.2 → 0.0.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/dist/module.json +1 -1
- package/dist/module.mjs +23 -7
- package/dist/runtime/types/index.d.ts +3 -3
- package/package.json +1 -1
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -1,6 +1,22 @@
|
|
|
1
1
|
import { useNuxt, addTemplate, resolvePath, logger, installModule, addVitePlugin, defineNuxtModule, createResolver, addComponentsDir, addImportsDir, addServerScanDir } from '@nuxt/kit';
|
|
2
|
+
import { toNonNullableArray } from '@resee-movies/utilities/arrays/to-non-nullable-array';
|
|
2
3
|
import { readFile } from 'node:fs/promises';
|
|
3
4
|
import { join } from 'node:path';
|
|
5
|
+
import { existsSync } from 'node:fs';
|
|
6
|
+
import { createRequire } from 'node:module';
|
|
7
|
+
import NuxtFontsModule from '@nuxt/fonts';
|
|
8
|
+
import NuxtPrimevueModule from '@primevue/nuxt-module';
|
|
9
|
+
|
|
10
|
+
function resolveModuleDirectory(entry, ...packagePaths) {
|
|
11
|
+
const packageName = entry.includes("/") ? entry.startsWith("@") ? entry.split("/").slice(0, 2).join("/") : entry.split("/")[0] : entry;
|
|
12
|
+
const require = createRequire(import.meta.url);
|
|
13
|
+
const lookupPaths = require.resolve.paths(entry)?.map((p) => join(p, packageName));
|
|
14
|
+
const directory = lookupPaths?.find((p) => existsSync(p));
|
|
15
|
+
if (directory && packagePaths.length) {
|
|
16
|
+
return join(directory, ...packagePaths);
|
|
17
|
+
}
|
|
18
|
+
return directory;
|
|
19
|
+
}
|
|
4
20
|
|
|
5
21
|
const IMPORT_REGEX = /(?<=\s|^|;|\})@import\s+["']tailwindcss["']/gmu;
|
|
6
22
|
function getDefaults(config) {
|
|
@@ -16,9 +32,9 @@ async function importCSS(nuxt = useNuxt(), options) {
|
|
|
16
32
|
const sources = nuxt.options._layers.map(
|
|
17
33
|
(layer) => layer.config.srcDir || layer.cwd
|
|
18
34
|
);
|
|
19
|
-
const plugins = options?.plugins ?? [];
|
|
35
|
+
const plugins = toNonNullableArray(options?.plugins ?? []);
|
|
20
36
|
if (options?.sources) {
|
|
21
|
-
sources.push(...options.sources);
|
|
37
|
+
sources.push(...toNonNullableArray(options.sources));
|
|
22
38
|
}
|
|
23
39
|
await nuxt.callHook("tailwindcss:sources:extend", sources);
|
|
24
40
|
const sourcesTemplate = addTemplate({
|
|
@@ -68,9 +84,9 @@ async function importCSS(nuxt = useNuxt(), options) {
|
|
|
68
84
|
write: true,
|
|
69
85
|
getContents: () => {
|
|
70
86
|
return [
|
|
71
|
-
`@import
|
|
87
|
+
`@import ${JSON.stringify(resolveModuleDirectory("tailwindcss"))};`,
|
|
72
88
|
`@import ${JSON.stringify(sourcesTemplate.dst)};`,
|
|
73
|
-
...(options?.imports ?? []).map((item) => `@import ${JSON.stringify(item)};`)
|
|
89
|
+
...toNonNullableArray(options?.imports ?? []).map((item) => `@import ${JSON.stringify(item)};`)
|
|
74
90
|
].join("\n");
|
|
75
91
|
}
|
|
76
92
|
}).dst
|
|
@@ -92,7 +108,7 @@ async function importCSS(nuxt = useNuxt(), options) {
|
|
|
92
108
|
}
|
|
93
109
|
|
|
94
110
|
async function importModules(nuxt = useNuxt()) {
|
|
95
|
-
await installModule(
|
|
111
|
+
await installModule(NuxtFontsModule, {
|
|
96
112
|
families: [
|
|
97
113
|
{
|
|
98
114
|
name: "Archivo",
|
|
@@ -102,7 +118,7 @@ async function importModules(nuxt = useNuxt()) {
|
|
|
102
118
|
}
|
|
103
119
|
]
|
|
104
120
|
});
|
|
105
|
-
await installModule(
|
|
121
|
+
await installModule(NuxtPrimevueModule, {
|
|
106
122
|
autoImport: false,
|
|
107
123
|
loadStyles: false,
|
|
108
124
|
importPT: {
|
|
@@ -169,7 +185,7 @@ const module = defineNuxtModule({
|
|
|
169
185
|
const plugins = options.tailwind?.plugins?.slice() ?? [];
|
|
170
186
|
const imports = options.tailwind?.plugins?.slice() ?? [];
|
|
171
187
|
sources.push(components);
|
|
172
|
-
plugins.push("@egoist/tailwindcss-icons");
|
|
188
|
+
plugins.push(resolveModuleDirectory("@egoist/tailwindcss-icons", "dist", "index.js"));
|
|
173
189
|
imports.push(stylesheet);
|
|
174
190
|
addComponentsDir({ path: components });
|
|
175
191
|
addImportsDir([composables]);
|
|
@@ -2,9 +2,9 @@ export interface ModuleOptions {
|
|
|
2
2
|
defaultColorMode?: 'lite' | 'dark';
|
|
3
3
|
usePreferredColorScheme?: boolean;
|
|
4
4
|
tailwind?: {
|
|
5
|
-
plugins?: string[];
|
|
6
|
-
sources?: string[];
|
|
7
|
-
imports?: string[];
|
|
5
|
+
plugins?: (string | undefined)[];
|
|
6
|
+
sources?: (string | undefined)[];
|
|
7
|
+
imports?: (string | undefined)[];
|
|
8
8
|
};
|
|
9
9
|
}
|
|
10
10
|
export interface ModuleHooks {
|
package/package.json
CHANGED