Skip to main content

Resolving

Nuxt Kit provides a set of utilities to help you resolve paths. These functions allow you to resolve paths relative to the current module, with unknown name or extension. Sometimes you need to resolve paths: relative to the current module, with unknown name or extension. For example, you may want to add a plugin that is located in the same directory as the module.

resolvePath

Resolves full path to a file or directory respecting Nuxt alias and extensions options. If path could not be resolved, normalized input path will be returned.

Type

Parameters

path: A path to resolve. options: Options to pass to the resolver:

Usage

resolveAlias

Resolves path aliases respecting Nuxt alias options.

Type

Parameters

path: A path to resolve. alias: An object of aliases. If not provided, it will be read from nuxt.options.alias.

findPath

Try to resolve first existing file in given paths.

Type

Parameters

paths: A path or an array of paths to resolve. options: Options to pass to the resolver. Same options as resolvePath. pathType: Whether to look for a file or directory. Default is 'file'.

Usage

createResolver

Creates resolver relative to base path.

Type

Parameters

basePath: A base path to resolve from. It can be a string or a URL.

Return Value

The createResolver function returns an object with the following properties:

Usage

Example: Resolving components from a package

Source

View source on GitHub