From a6eef6ae7ff7605fec4a892d63006c87fc5b3dc1 Mon Sep 17 00:00:00 2001 From: Benjamin Canac Date: Tue, 23 Nov 2021 17:47:52 +0100 Subject: [PATCH] chore: fix plugin import --- src/dirs.ts | 11 +++++++++++ src/index.ts | 3 ++- 2 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 src/dirs.ts diff --git a/src/dirs.ts b/src/dirs.ts new file mode 100644 index 00000000..af2cb27d --- /dev/null +++ b/src/dirs.ts @@ -0,0 +1,11 @@ +import { fileURLToPath } from 'url' +import { resolve } from 'pathe' + +export const distDir = resolve(typeof __dirname === 'undefined' ? fileURLToPath(import.meta.url) : __dirname) + +const _makeResolve = (base: string) => { + return (...p: string[]) => resolve(base, ...p) +} + +export const runtimeDir = resolve(distDir, 'runtime') +export const resolveRuntimeDir = _makeResolve(runtimeDir) diff --git a/src/index.ts b/src/index.ts index dbdd6b99..70fba213 100644 --- a/src/index.ts +++ b/src/index.ts @@ -2,6 +2,7 @@ import { resolve, join } from 'pathe' import { defineNuxtModule, installModule, addPlugin, resolveModule } from '@nuxt/kit' import { colors } from '@unocss/preset-uno' import type { UnocssNuxtOptions } from '@unocss/nuxt' +import { runtimeDir } from './dirs' export default defineNuxtModule({ name: '@nuxthq/ui', @@ -113,7 +114,7 @@ export default defineNuxtModule({ await installModule(nuxt, { src: '@unocss/nuxt', options }) - addPlugin(resolveModule('./plugin', { paths: resolve(__dirname, 'runtime') }), { append: true }) + addPlugin(resolveModule('./plugin', { paths: runtimeDir }), { append: true }) const componentsDir = resolve(__dirname, 'components')