🚨 Shai-Hulud Strikes Again:834 Packages Compromised.Technical Analysis →
Socket
Book a DemoInstallSign in
Socket

esbuild-auto-path-plugin

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

esbuild-auto-path-plugin

Plugin for transforming bundles to use an auto path for assets.

latest
Source
npmnpm
Version
1.3.0
Version published
Maintainers
1
Created
Source

esbuild-auto-path-plugin

A plugin for esbuild to allow referencing files relative to the path of the JavaSCript. This can be useful to work in a micro frontend setup where the individual files of one micro frontend are served from a different path than the other micro frontends, i.e., no common public path can be determined.

Usage

Install the plugin:

npm i esbuild-auto-path-plugin --save-dev

Now in your esbuild configuration file you can do:

const { build } = require('esbuild');
const { autoPathPlugin } = require('esbuild-auto-path-plugin');

build({
  // ...
  plugins: [autoPathPlugin()],
});

At this point you can reference an asset file (e.g., .jpg) in any file, e.g., in a TypeScript asset

import someImage from './my.jpg';

The reference to the generated asset file will be done via the automatically (i.e., at runtime) determined path.

File Extensions

This plugin takes all extensions mapped to the file type in your esbuild configuration. However, you can also use the plugin to generate you this list of files. By default (i.e., if you don't specify any option and have not introduced any custom loader mapping) the following extensions will be mapped:

  • .png
  • .svg
  • .jpg
  • .jpeg
  • .webp
  • .mp4
  • .mp3
  • .ogg
  • .wav
  • .ogv
  • .wasm
  • .gif

To override this list you can just pass in the extensions like this:

const { build } = require('esbuild');
const { autoPathPlugin } = require('esbuild-auto-path-plugin');

build({
  plugins: [autoPathPlugin({
    defaultExtensions: [".png", ".mov", ".woff"]
  })],
});

License

This plugin is released using the MIT license. For more information see the LICENSE file.

Keywords

plugin

FAQs

Package last updated on 23 Jun 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts