From 4f2d2e586307da050540e70b89c0a3d9ab5616a7 Mon Sep 17 00:00:00 2001 From: rowan Date: Tue, 22 Apr 2025 01:15:18 -0500 Subject: [PATCH] add configuration options --- src/index.js | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/index.js b/src/index.js index 616a392..cdab12a 100644 --- a/src/index.js +++ b/src/index.js @@ -1,14 +1,17 @@ import fs from 'node:fs/promises' -export const wgsl = () => ({ - name: 'esbuild-plugin-wgsl', - setup(build) { - build.onLoad({ filter: /\.wgsl$/ }, async args => { - const contents = await fs.readFile(args.path, 'utf8') +export const wgsl = ({ filterWith, filterExtension }) => ({ + name: 'esbuild-plugin-wgsl', + setup(build) { + const filter = filterExtension || true ? /\.wgsl$/ : /.*/ + build.onLoad({ filter }, async args => { + if (!filterWith || args.filter.with === 'wgsl') { + const contents = await fs.readFile(args.path, 'utf8') - return { contents } - }) - } + return { contents, loader: 'text' } + } + }) + } }) export default wgsl