Skip to content

Commit

Permalink
build: use esbuild to compile (#1185)
Browse files Browse the repository at this point in the history
  • Loading branch information
Fdawgs authored Jan 10, 2023
1 parent ce49294 commit cc892ff
Show file tree
Hide file tree
Showing 8 changed files with 526 additions and 7 deletions.
3 changes: 2 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ out

# Nuxt.js build / generate output
.nuxt
dist

# Gatsby files
.cache/
Expand Down Expand Up @@ -128,7 +127,9 @@ src/temp*/
.husky/
.vscode/
docs/
src/
.env.template
.esbuild.js
.eslintrc.js
.gitignore
.pm2.config.js
Expand Down
20 changes: 20 additions & 0 deletions .esbuild.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
const esbuild = require("esbuild");
const { globPlugin } = require("esbuild-plugin-glob");

esbuild.build({
entryPoints: ["src/**/!(*.test).*"],
format: "cjs",
loader: {
".html": "copy",
".ico": "copy",
".png": "copy",
".svg": "copy",
},
logLevel: "info",
minify: true,
outdir: "dist",
packages: "external",
platform: "node",
plugins: [globPlugin()],
target: "node18",
});
3 changes: 3 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ updates:
include: scope
prefix: build
directory: /
ignore:
- dependency-name: esbuild
- dependency-name: esbuild-plugin-glob
open-pull-requests-limit: 20
schedule:
interval: monthly
5 changes: 4 additions & 1 deletion .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ jobs:
cache: npm
node-version: lts/*

- name: Build
run: npm run build

- name: Remove dev values from package.json
run: |
npm pkg delete commitlint devDependencies jest nodemonConfig scripts
Expand All @@ -58,7 +61,7 @@ jobs:
.dockerignore .env.template .pm2.config.js
docker-compose.yml Dockerfile LICENSE
package.json package-lock.json README.md
ocr_lang_data src -x \src\**\*.test.js
dist ocr_lang_data
- name: Upload release asset
uses: actions/upload-release-asset@v1
Expand Down
22 changes: 22 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,28 @@ jobs:
parallel: true
flag-name: run-${{ matrix.node-version }}-${{ matrix.os }}

build:
name: Build
if: github.event.pull_request.draft == false
runs-on: ubuntu-latest
steps:
- name: Check out repo
uses: actions/checkout@v3
with:
persist-credentials: false

- name: Setup Node
uses: actions/setup-node@v3
with:
cache: npm
node-version: lts/*

- name: Install
run: npm ci --ignore-scripts

- name: Run esbuild
run: npm run build

lint-docker-file:
name: Lint Dockerfile
if: github.event.pull_request.draft == false
Expand Down
2 changes: 1 addition & 1 deletion .pm2.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module.exports = {
exec_mode: "cluster",
instances: "max",
name,
script: "./src/app.js",
script: "./dist/app.js",
watch: [".env"],
},
],
Expand Down
Loading

0 comments on commit cc892ff

Please sign in to comment.