excalidraw/scripts/buildExample.mjs
Aakansha Doshi a8064ba3ee
build: Welcome ESM and Bye Bye UMD (#7441)
* build: Welcome ESM and Bye Bye UMD

* remove package

* create unbundled esm build

* update script for example

* fix typo

* dummy commit

* update autorelease script to build esm

* revert dummy commit

* move react, react-dom and testing library to dev dependencies

* remove entry.js, publicPath and yarn install:deps script

* fix

* upgrade esbuild to fix glob import error for locales

* remove webpack chunk names as thats not needed anymore

* marking the code sideeffects free

* make the library tree-shakeable and move fonts to fonts directory

* allow side effects for css, scss files

* remove tree-shaking

* comment code for tree shaking

* move to vite for example

* bye bye webpack

* ignore ts

* separate build and output dir

* use esbuild for creating bundle for example

* update output dir

* lint

* create browser dev build with source maps and prod with minification

* add dev and prod builds for bundler

* lint

* update script

* remove await

* load prod build

* create minified build in dist

* prod and dev builds using export field

* remove import.meta

* dummy

* define import.meta prod and dev

* fix

* export types

* add types field

* typo

* lint

* Update scripts/buildPackage.js

* move types inside export

* newline
2024-01-01 20:18:44 +05:30

35 lines
807 B
JavaScript

import * as esbuild from "esbuild";
import { sassPlugin } from "esbuild-sass-plugin";
import { execSync } from "child_process";
const createDevBuild = async () => {
return await esbuild.build({
entryPoints: ["example/index.tsx"],
outfile: "example/public/bundle.js",
define: {
"import.meta.env": "{}",
},
bundle: true,
format: "esm",
plugins: [sassPlugin()],
loader: {
".woff2": "dataurl",
".html": "copy",
},
});
};
const startServer = async (ctx) => {
await ctx.serve({
servedir: "example/public",
port: 5001,
});
};
execSync(
`rm -rf example/public/dist && yarn build:esm && cp -r dist example/public`,
);
const ctx = await createDevBuild();
// await startServer(ctx);
// console.info("Hosted at port http://localhost:5001!!");