Skip to content

Instantly share code, notes, and snippets.

@adamjarling
Last active January 3, 2022 21:36
Show Gist options
  • Save adamjarling/c045662f023e8acd97b13cc2f1726cf0 to your computer and use it in GitHub Desktop.
Save adamjarling/c045662f023e8acd97b13cc2f1726cf0 to your computer and use it in GitHub Desktop.
const { build } = require("esbuild");
const { dependencies } = require("./package.json");
const entryFile = "src/index.tsx";
const shared = {
bundle: true,
entryPoints: [entryFile],
// Treat all dependencies in package.json as externals to keep bundle size to a minimum
external: Object.keys(dependencies),
logLevel: "info",
minify: true,
sourcemap: true,
};
build({
...shared,
format: "esm",
outfile: "./dist/index.esm.js",
target: ["esnext", "node12.22.0"],
});
build({
...shared,
format: "cjs",
outfile: "./dist/index.cjs.js",
target: ["esnext", "node12.22.0"],
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment