Created
July 23, 2023 19:15
-
-
Save Loskir/4911b5c4e598939e39237af98c7d2874 to your computer and use it in GitHub Desktop.
Using esbuild to build a node.js project
This file contains hidden or 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
import { build } from 'esbuild' | |
import { glob } from 'glob' | |
import { rimraf } from 'rimraf' | |
async function main() { | |
console.time('build') | |
await rimraf('./dist') | |
const globOptions = { ignore: ['node_modules/**', 'dist/**'] } | |
const files = await glob('**/*.{js,ts,json}', globOptions) | |
await build({ | |
bundle: false, | |
format: 'cjs', | |
platform: 'node', | |
outdir: 'dist', | |
target: 'es2020', | |
entryPoints: files, | |
loader: { | |
'.json': 'copy', | |
'.d.ts': 'copy' | |
} | |
}) | |
console.timeEnd('build') | |
} | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment