esbuild plugin for creating path aliases, allowing dynamic resolution of import paths based on conditions like environment variables. Version 0.2.1 is the current stable release. The plugin requires absolute file paths for aliases. It is a lightweight alternative to using esbuild's built-in `alias` or custom onResolve plugins, specifically designed for conditional aliasing. It ships TypeScript definitions and is published on npm.
npm install esbuild-plugin-aliasVerified import paths — ran on the pinned version, not inferred.
Creates an alias for 'settings.env' resolving to a path that depends on the NODE_ENV environment variable.
Use path.resolve() or require.resolve() to convert relative paths to absolute.
Use path.resolve(__dirname, relativePath) to generate absolute path.
N/A
Use path.resolve() to convert the value to an absolute path.
Use default import: import alias from 'esbuild-plugin-alias' or const alias = require('esbuild-plugin-alias').Use import.meta.url with fileURLToPath or use path.dirname(new URL(import.meta.url).pathname).