Skip to content

Commit 5e2243c

Browse files
authored
Merge pull request #1 from vuelessjs/VL-92_Fix-type-errors-in-nuxt-module_Dmytro-Holdobin
VL-92_Fix-type-errors-in-nuxt-module_Dmytro-Holdobin
2 parents 69edc88 + 69f15ec commit 5e2243c

File tree

8 files changed

+68
-22
lines changed

8 files changed

+68
-22
lines changed

global.d.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
declare module '@vueless/*'
2+
declare module '@vueless'
3+
declare module 'vueless'
4+
declare module 'vueless/*'

package-lock.json

Lines changed: 14 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,19 @@
2727
"release:major": "release-it major --ci --npm.publish --git.tag --github.release",
2828
"release": "npm run lint && npm run test && npm run prepack && changelogen --release && npm publish && git push --follow-tags",
2929
"lint": "eslint .",
30+
"lint:ci": "eslint --no-fix --max-warnings=0",
3031
"test": "vitest run",
3132
"test:watch": "vitest watch",
32-
"test:types": "vue-tsc --noEmit && cd playground && vue-tsc --noEmit"
33+
"test:types": "vue-tsc --noEmit && cd playground && vue-tsc --noEmit",
34+
"install": "npx nuxi prepare"
3335
},
3436
"dependencies": {
3537
"@nuxt/kit": "^3.13.1",
3638
"@nuxtjs/tailwindcss": "^6.12.1",
37-
"@vueless/plugin-vite": "^0.0.62",
38-
"vueless": "^0.0.357"
39+
"@vueless/plugin-vite": "^0.0.64",
40+
"defu": "^6.1.4",
41+
"pathe": "^1.1.2",
42+
"vueless": "^0.0.400"
3943
},
4044
"devDependencies": {
4145
"@nuxt/devtools": "^1.4.1",

playground/app.vue

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@
55
>
66
<UHeader label="Vueless UI is ready!" />
77

8+
<UIcon
9+
internal
10+
name="close"
11+
/>
12+
813
<UButton
914
color="lime"
1015
label="Button"

playground/nuxt.config.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
export default defineNuxtConfig({
22
compatibilityDate: '2024-09-13',
3-
modules: ['../src/module'],
3+
modules: ['@vueless/module-nuxt'],
44
devtools: { enabled: true },
55
tailwindcss: {
6-
content: ['../node_modules/vueless/**/*.{js,ts,vue}'],
6+
config: {
7+
content: ['../node_modules/vueless/**/*.{js,ts,vue}'],
8+
},
79
},
810
})

src/module.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,7 @@ import { COMPONENTS } from '@vueless/plugin-vite/constants.js'
33
import { Vueless } from '@vueless/plugin-vite'
44
import installTailwind from './tailwind'
55

6-
// Module options TypeScript interface definition
7-
export interface ModuleOptions {}
8-
9-
export default defineNuxtModule<ModuleOptions>({
6+
export default defineNuxtModule({
107
meta: {
118
name: '@vueless/module-nuxt',
129
configKey: 'vueless',
@@ -37,6 +34,7 @@ export default defineNuxtModule<ModuleOptions>({
3734
for (const componentName in COMPONENTS) {
3835
await addComponent({
3936
name: componentName,
37+
mode: componentName === 'UIcon' ? 'client' : 'all', // TODO: Find reason why icons can't load on dev server
4038
filePath: `vueless/${COMPONENTS[componentName].folder}/${componentName}.vue`,
4139
})
4240
}

src/tailwind.ts

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,23 @@
1+
import path from 'node:path'
12
import { addTemplate, installModule, useNuxt } from '@nuxt/kit'
2-
import { createTailwindSafelist } from '@vueless/plugin-vite/utils/tailwindSafelist'
3+
import { createTailwindSafelist } from '@vueless/plugin-vite/utils/tailwindSafelist.js'
34
import { join } from 'pathe'
45
import { defu } from 'defu'
56

6-
export default async function installTailwind(_nuxt = useNuxt()) {
7+
import type { Nuxt } from './types'
8+
9+
export default async function installTailwind(_nuxt: Nuxt = useNuxt()) {
710
/* Generate tailwind safelist before module installed */
8-
await createTailwindSafelist()
11+
await createTailwindSafelist({
12+
targetFiles: [
13+
'components',
14+
'layouts',
15+
'pages',
16+
path.join(process.cwd(), 'app.vue'),
17+
path.join(process.cwd(), 'error.vue'),
18+
path.join(process.cwd(), 'playground', 'app.vue'),
19+
],
20+
})
921

1022
/* Add vueless tailwind config template */
1123
const vuelessConfigFile = addTemplate({
@@ -28,10 +40,15 @@ export default async function installTailwind(_nuxt = useNuxt()) {
2840
const configPaths = [vuelessConfigFile.dst, join(_nuxt.options.rootDir, 'tailwind.config')]
2941

3042
/* Get tailwind user configs */
31-
const { configPath: userConfigPath = [] || "", ...twModuleConfig } = _nuxt.options.tailwindcss ?? {}
43+
const { configPath: userConfigPath = [], ...twModuleConfig } = _nuxt.options.tailwindcss ?? {}
3244

3345
/* Merge vueless, default, and user tailwind config paths */
34-
typeof userConfigPath === 'string' ? configPaths.push(userConfigPath) : configPaths.push(...userConfigPath)
46+
if (typeof userConfigPath === 'string') {
47+
configPaths.push(userConfigPath)
48+
}
49+
else {
50+
configPaths.push(...userConfigPath)
51+
}
3552

3653
/* Install tailwind module */
3754
await installModule('@nuxtjs/tailwindcss', defu({

src/types.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import type { ModuleOptions as TailwindcssMoudleOptions } from '@nuxtjs/tailwindcss'
2+
import type { Nuxt as DefaultNuxt, NuxtOptions as DefaultNuxtOptions } from '@nuxt/schema'
3+
4+
export interface NuxtOptions extends DefaultNuxtOptions {
5+
tailwindcss?: TailwindcssMoudleOptions
6+
}
7+
8+
export interface Nuxt extends DefaultNuxt {
9+
options: NuxtOptions
10+
}

0 commit comments

Comments
 (0)