lc-bun-plugin
Version:
Some bun bundler plugins.
22 lines (20 loc) • 618 B
JavaScript
import fs from "fs";
export function bunPluginSvg() {
const BunPluginSvg = {
name: "import svg as raw string",
setup(build) {
build.onLoad(
{ filter: /\.svg$/, namespace: "file" },
async (args) => {
const filePath = args.path;
const svgCode = fs.readFileSync(filePath, "utf8");
return {
contents: svgCode,
loader: "text",
};
},
);
},
};
return BunPluginSvg;
}