UNPKG

esbuild-plugin-version-injector

Version:

An esbuild plugin to inject your application's version number or today's date into your files

65 lines (62 loc) 2.2 kB
import { OnLoadOptions, Plugin } from 'esbuild'; declare enum VersionOrCurrentDate { Version = "version", CurrentDate = "current-date" } interface PluginOptions { /** * The [esbuild filter](https://esbuild.github.io/plugins/#filters) to * apply for the filtering of files to parse with this plugin * * @default /.*​/ */ filter?: OnLoadOptions['filter']; /** * The [esbuild namespace](https://esbuild.github.io/plugins/#namespaces) to * which the plugin should apply * * @default undefined */ namespace?: OnLoadOptions['namespace']; /** * Whether the plugin should inject the package.json version or the * current date (in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format) * * @default 'version' */ versionOrCurrentDate?: 'version' | 'current-date' | VersionOrCurrentDate; /** * The default identifier that should be searched within the code and replaced with either the * the version or the current date as configured by {@link PluginOptions.versionOrCurrentDate}. * * @default '[VI]{{inject}}[/VI]' */ injectTag?: string; /** * Relative path to project's package.json * * Note if you set {@link PluginOptions.versionOrCurrentDate} to 'current-date' this option will be ignored. * * @default './package.json' */ packageJsonPath?: string; /** * Whether to disable the `onLoad` trigger, which is used by default. * * In most cases you will not want to set this to `true`, * but it can be useful if you have specified a custom `loader` mapper in `esbuild` through * ```ts * esbuild.build({ ...otherOptions, loader: { '.js': 'jsx' } }); * ``` * * @default undefined */ disableOnLoadTrigger?: boolean; } declare function esbuildPluginVersionInjector(options?: PluginOptions): Plugin; /** * The [esbuild-plugin-version-injector](https://github.com/favware/esbuild-plugin-version-injector/#readme) version * that you are currently using. */ declare const version: string; export { PluginOptions, VersionOrCurrentDate, esbuildPluginVersionInjector, version };