Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tinrab/esbuild-plugin-copy-import
https://github.com/tinrab/esbuild-plugin-copy-import
Last synced: 3 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/tinrab/esbuild-plugin-copy-import
- Owner: tinrab
- License: mit
- Created: 2024-05-28T02:11:55.000Z (6 months ago)
- Default Branch: main
- Last Pushed: 2024-05-28T02:25:18.000Z (6 months ago)
- Last Synced: 2024-08-08T00:05:35.008Z (3 months ago)
- Language: TypeScript
- Size: 5.86 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
An esbuild plugin that copies imported module to the destination directory and sets the imported value to the relative path.
## Install
```bash
npm install -D esbuild-plugin-copy-import
```## Usage
```js
import copyImportPlugin from 'esbuild-plugin-copy-import';/** @type esbuild.BuildOptions */
const config = {
plugins: [
copyImportPlugin({
// Custom filter, defaults to /.+\?url/
filter: /\.wasm\?url$/,
// Optional path inside the `outDir`
outRelativePath: 'dist-wasm',
// Defaults to `?url.
// This will be stripped from the import path.
suffix: '?url',
}),
],
// ...
};
``````ts
import wasmModuleUrl from 'example.wasm?url';// In this example, this runs inside ./dist/index.js
// and the `example.wasm` file is located at ./dist/dist-wasm/example.wasm
assert.strictEqual(wasmModuleUrl, './dist-wasm/example.wasm');
```