Use esbuild for worker

This commit is contained in:
adrinr 2023-03-02 17:03:56 +01:00
parent e8e77cc140
commit 87aaf3b172
3 changed files with 21 additions and 7 deletions

View File

@ -1,6 +1,10 @@
{
"watch": ["src", "../backend-core", "../../../budibase-pro/packages/pro"],
"ext": "js,ts,json",
"ignore": ["src/**/*.spec.ts", "src/**/*.spec.js", "../backend-core/dist/**/*"],
"exec": "ts-node src/index.ts"
"ignore": [
"src/**/*.spec.ts",
"src/**/*.spec.js",
"../backend-core/dist/**/*"
],
"exec": "node ../../scripts/build && node ./dist/index.js"
}

View File

@ -21,7 +21,7 @@
"run:docker:cluster": "pm2-runtime start pm2.config.js",
"build:docker": "docker build . -t worker-service --label version=$BUDIBASE_RELEASE_VERSION",
"dev:stack:init": "node ./scripts/dev/manage.js init",
"dev:builder": "npm run dev:stack:init && nodemon",
"dev:builder": "npm run dev:stack:init && rimraf dist/ && nodemon",
"test": "bash scripts/test.sh",
"test:watch": "jest --watch",
"env:multi:enable": "node scripts/multiTenancy.js enable",

View File

@ -1,5 +1,9 @@
const start = Date.now()
const glob = require("glob")
const fs = require("fs")
var path = require("path")
const { build } = require("esbuild")
const sveltePlugin = require("esbuild-svelte")
@ -33,8 +37,14 @@ build({
platform: "node",
outfile: "dist/index.js",
}).then(() => {
console.log(
"\x1b[32m%s\x1b[0m",
`Build successfully in ${(Date.now() - start) / 1000} seconds`
)
glob(`${process.cwd()}/src/**/*.hbs`, {}, (err, files) => {
for (const file of files) {
fs.copyFileSync(file, `${process.cwd()}/dist/${path.basename(file)}`)
}
console.log(
"\x1b[32m%s\x1b[0m",
`Build successfully in ${(Date.now() - start) / 1000} seconds`
)
})
})