buildExample.mjs 1012 B

12345678910111213141516171819202122232425262728293031323334353637
  1. import * as esbuild from "esbuild";
  2. import { sassPlugin } from "esbuild-sass-plugin";
  3. import { execSync } from "child_process";
  4. const createDevBuild = async () => {
  5. return await esbuild.build({
  6. entryPoints: ["../../examples/excalidraw/with-script-in-browser/index.tsx"],
  7. outfile:
  8. "../../examples/excalidraw/with-script-in-browser/public/bundle.js",
  9. define: {
  10. "import.meta.env": "{}",
  11. },
  12. bundle: true,
  13. format: "esm",
  14. plugins: [sassPlugin()],
  15. external: ["@excalidraw/utils"],
  16. loader: {
  17. ".woff2": "dataurl",
  18. ".html": "copy",
  19. },
  20. });
  21. };
  22. const startServer = async (ctx) => {
  23. await ctx.serve({
  24. servedir: "example/public",
  25. port: 5001,
  26. });
  27. };
  28. execSync(
  29. `rm -rf ../../examples/excalidraw/with-script-in-browser/public/dist && yarn build:esm && cp -r dist ../../examples/excalidraw/with-script-in-browser/public`,
  30. );
  31. const ctx = await createDevBuild();
  32. // await startServer(ctx);
  33. // console.info("Hosted at port http://localhost:5001!!");