configuration options for the httpPluginSetup and httpPlugin functions.

interface HttpPluginSetupConfig {
    filters: RegExp[];
    namespace: string;
    globalImportMap?: ImportMap;
    resolvePath: (...segments: string[]) => string;
    defaultLoader: Loader;
    acceptLoaders?: Loader[];
}

Hierarchy

Properties

filters: RegExp[]

the regex filters which the plugin's resolvers should use for the initial interception of resource-paths.

[/^https?\:///, /^file\:///] (captures "http://", "https://", and "file://" uris)

namespace: string

the namespace that the plugin should use.

if the plugin requires multiple namespaces, it should append additional characters to this base namespace for consistency and collision resistance.

globalImportMap?: ImportMap

specify a global import-map for aliases to resources.

the full import-map within the body of the resolver function should be a merger between this global import-map, and the import-map acquired from the plugin data (i.e. CommonPluginData.importMap). the plugin data's import-map will take a higher priority in case of conflicting key (i.e. same alias key but different absolute path values).

the resolve function will always look for a match for args.path inside of the import-map, before resolving it with respect to the current importer or resolve-directory (i.e. args.importer or args.resolveDir).

{} (empty object/dictionary)

resolvePath: (...segments: string[]) => string

a function that joins/resolves path segments to an absolute path (i.e. a path that the plugin itself can recognize as an absolute path).

typically, only two or one segments are provided at a time, but it's better if your function accepts variable number of segments.

defaultLoader: Loader

the default loader that the plugin's loader should use for unidentified content types.

if you would like to use esbuild's own default loader, set the value to "default".

acceptLoaders?: Loader[]

only accept the following subset of loaders when auto content-detection is used for guessing the loader type.

Note

if there is no intersection between the set of guessed loaders, and this set of acceptLoaders, then the default loader (defaultLoader) will be used as a fallback.

all available esbuild loaders