Skip to content

Commit

Permalink
build(esbuild): add windows compatible build script
Browse files Browse the repository at this point in the history
  • Loading branch information
wd-David committed Apr 28, 2022
1 parent 8f12b2b commit dd3fe39
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
30 changes: 30 additions & 0 deletions build.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/* eslint-disable @typescript-eslint/no-var-requires */
/* eslint-disable no-undef */
const fs = require('fs')
const path = require('path')
const esbuild = require('esbuild')

let fileArray = []
const getFilesRecursively = (dir) => {
const files = fs.readdirSync(dir)
files.forEach((file) => {
const filePath = path.join(dir, file)
if (fs.statSync(filePath).isDirectory()) {
getFilesRecursively(filePath)
} else {
fileArray.push(filePath)
}
})
}
getFilesRecursively('src')

const entryPoints = fileArray.filter((file) => file.endsWith('.ts'))

esbuild.build({
entryPoints,
logLevel: 'info',
outdir: 'build',
minify: true,
bundle: true,
platform: 'node'
})
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"prepare": "husky install",
"dev": "nodemon",
"build": "rm -rf build && esbuild `find src \\( -name '*.ts' \\)` --platform=node --outdir=build --bundle --minify",
"build:windows": "rm -rf build && node ./build.js",
"format": "prettier --write 'src/**/*.{js,ts,json,md}'",
"lint": "prettier --check 'src/**/*.{js,ts,json,md}' && eslint --ignore-path .gitignore .",
"cz": "cz",
Expand Down

0 comments on commit dd3fe39

Please sign in to comment.