buildExample.mjs 977 B

123456789101112131415161718192021222324252627282930313233343536
  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. loader: {
  16. ".woff2": "dataurl",
  17. ".html": "copy",
  18. },
  19. });
  20. };
  21. const startServer = async (ctx) => {
  22. await ctx.serve({
  23. servedir: "example/public",
  24. port: 5001,
  25. });
  26. };
  27. execSync(
  28. `rm -rf ../../examples/excalidraw/with-script-in-browser/public/dist && yarn build:esm && cp -r dist ../../examples/excalidraw/with-script-in-browser/public`,
  29. );
  30. const ctx = await createDevBuild();
  31. // await startServer(ctx);
  32. // console.info("Hosted at port http://localhost:5001!!");