1
0
Fork 0
tsgames/build/filePlugin.ts

22 lines
584 B
TypeScript

import { plugin, type BunPlugin } from "bun";
const filePlugin: BunPlugin = {
name: "File loader",
async setup(build) {
build.onLoad({ filter: /\.glsl$/ }, async (args) => {
console.log(args);
const text = await Bun.file(args.path).text();
return {
contents: `
const text = (${JSON.stringify(text)});
export default text;
`,
loader: 'js',
};
});
}
};
plugin(filePlugin);
export default filePlugin;