diff --git a/build.js b/build.js new file mode 100644 index 0000000..cb06687 --- /dev/null +++ b/build.js @@ -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' +}) diff --git a/package.json b/package.json index df7b936..8adacab 100644 --- a/package.json +++ b/package.json @@ -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",