Skip to content

resolve

  • Type: optional resolve: object

alias?

  • Type: optional alias: Record<string, string | false | string[]>

Example

js
resolve: {
  alias: {
    '@': '/src',
    'utils': './src/utils',
  }
}

WARNING

resolve.alias will not call resolveId hooks of other plugin. If you want to call resolveId hooks of other plugin, use viteAliasPlugin from rolldown/experimental instead. You could find more discussion in this issue

aliasFields?

  • Type: optional aliasFields: string[][]

Fields in package.json to check for aliased paths.

conditionNames?

  • Type: optional conditionNames: string[]

Condition names to use when resolving exports in package.json. Defaults based on platform and import kind:

  • Browser platform: ["import", "browser", "default"] for import statements, ["require", "browser", "default"] for require() calls
  • Node platform: ["import", "node", "default"] for import statements, ["require", "node", "default"] for require() calls
  • Neutral platform: ["import", "default"] for import statements, ["require", "default"] for require() calls

exportsFields?

  • Type: optional exportsFields: string[][]

Fields in package.json to check for exports.

extensionAlias?

  • Type: optional extensionAlias: Record<string, string[]>

Map of extensions to alternative extensions.

With writing import './foo.js' in a file, you want to resolve it to foo.ts instead of foo.js. You can achieve this by setting: extensionAlias: { '.js': ['.ts', '.js'] }.

extensions?

  • Type: optional extensions: string[]

Extensions to try when resolving files. These are tried in order from first to last.

Default

ts
['.tsx', '.ts', '.jsx', '.js', '.json']

mainFields?

  • Type: optional mainFields: string[]

Fields in package.json to check for entry points. Defaults based on platform:

  • Node: ['main', 'module']
  • Browser: ['browser', 'module', 'main']
  • Neutral: [] (relies on exports field)

mainFiles?

  • Type: optional mainFiles: string[]

Filenames to try when resolving directories.

Default

ts
['index']

modules?

  • Type: optional modules: string[]

Directories to search for modules.

Default

ts
['node_modules']
  • Type: optional symlinks: boolean

Whether to follow symlinks when resolving modules.

Default

ts
true

tsconfigFilename?

  • Type: optional tsconfigFilename: string

Deprecated

Use the top-level tsconfig option instead.

Released under the MIT License.