import { build } from "./deps.ts";

// bundle & minify app.css
const { outputFiles } = await build({
  entryPoints: ["https://scrapbox.io/api/code/takker/scrapbox-icon-button/script.js"],
  bundle: true,
  minify: true,
  write: false,
  plugins: [{
    name: "http",
    setup: ({ onLoad, onResolve }) => {
      onResolve({ filter: /.*/ }, ({ path, importer}) => {
        return {
          path: new URL(path, importer || path).href,
          namespace: "http",
        };
      });
      onLoad({ filter: /.*/, namespace: name }, async ({ path }) => ({
        contents: await (await fetch(path)).text(),
        loader: "js",
      }));
    },
  }],
});

console.log(outputFiles[0].text);