Skip to content

paths

  • Type: optional paths: Record<string, string> | (id) => string

Maps external module IDs to paths.

Allows customizing the path used when importing external dependencies. This is particularly useful for loading dependencies from CDNs or custom locations.

  • Object form: Maps module IDs to their replacement paths
  • Function form: Takes a module ID and returns its replacement path

Examples

js
{
  paths: {
    'd3': 'https://cdn.jsdelivr.net/npm/d3@7'
  }
}
js
{
  paths: (id) => {
    if (id.startsWith('lodash')) {
      return `https://cdn.jsdelivr.net/npm/${id}`
    }
    return id
  }
}

Released under the MIT License.