Esbuild Plugin Meta Url • A file loader plugin for esbuild for constructed URLs using import metadata.
How it works
Esbuild Plugin Meta Url looks for new URL('path/to/file.png', import.meta.url)
in JavaScript and TypeScript files and instructs esbuild to copy referenced files. This is a standard version of the file loader.
import img from './logo.png';
const img = new URL('./logo.png', import.meta.url).href;
Install
$ npm i @chialab/esbuild-plugin-meta-url -D
$ yarn add @chialab/esbuild-plugin-meta-url -D
Usage
import esbuild from 'esbuild';
import metaUrlPlugin from '@chialab/esbuild-plugin-meta-url';
await esbuild.build({
plugins: [
metaUrlPlugin(),
],
});
License
Esbuild Plugin Meta Url is released under the MIT license.