Skip to content

Commit

Permalink
fix: add #font-loader alias for import composables
Browse files Browse the repository at this point in the history
  • Loading branch information
ivodolenc committed Dec 2, 2022
1 parent 8af68d4 commit 257f20f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 10 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ Import the function where you need it.
</template>

<script setup lang="ts">
import { useLocalFont } from 'nuxt-font-loader/app'
import { useLocalFont } from '#font-loader'
useLocalFont([
{
Expand Down Expand Up @@ -175,7 +175,7 @@ Import the function where you need it.
</template>

<script setup lang="ts">
import { useExternalFont } from 'nuxt-font-loader/app'
import { useExternalFont } from '#font-loader'
useExternalFont([
{
Expand Down
4 changes: 0 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@
".": {
"import": "./dist/module.mjs",
"types": "./dist/types.d.ts"
},
"./app": {
"import": "./dist/runtime/composables/index.mjs",
"types": "./dist/runtime/composables/index.d.ts"
}
},
"files": [
Expand Down
9 changes: 5 additions & 4 deletions src/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,13 @@ export default defineNuxtModule<ModuleOptions>({
const { local, external, autoImport } = options
const head = nuxt.options.app.head

if (autoImport) {
const { resolve } = createResolver(import.meta.url)
nuxt.options.build.transpile.push(resolve('./runtime'))
const { resolve } = createResolver(import.meta.url)
nuxt.options.build.transpile.push(resolve('./runtime'))

const composables = resolve('./runtime/composables')
const composables = resolve('./runtime/composables')
nuxt.options.alias['#font-loader'] = composables

if (autoImport) {
addImports([
{
name: 'useLocalFont',
Expand Down

0 comments on commit 257f20f

Please sign in to comment.