Last active
January 3, 2022 21:36
-
-
Save adamjarling/c045662f023e8acd97b13cc2f1726cf0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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