Skip to content
This repository has been archived by the owner on Oct 27, 2024. It is now read-only.

Commit

Permalink
Merge pull request #6 from rndquu/build/add-build-scripts
Browse files Browse the repository at this point in the history
Build/add build scripts
  • Loading branch information
rndquu authored Oct 15, 2023
2 parents 364fd7b + 637a7a7 commit 0517dd0
Show file tree
Hide file tree
Showing 15 changed files with 65 additions and 68 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ jobs:
run: yarn install

- name: Build
run: yarn build
run: yarn build:prod

- name: Add commit SHA file to build folder
run: echo -n $(echo "${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}" | cut -c1-7) > scripts/out/commit.txt
run: echo -n $(echo "${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}" | cut -c1-7) > build/commit.txt

- name: Prepare Deployment Artifact
env:
Expand All @@ -41,7 +41,7 @@ jobs:
echo "event_name=$EVENT_NAME,pr_number=$PR_NUMBER,sha=$SHA"
mkdir -p ./pr
echo "event_name=$EVENT_NAME,pr_number=$PR_NUMBER,sha=$SHA," > ./pr/pr_number
cd ./scripts/out && zip -r ../../pr/pull-request.zip ./*
cd ./build && zip -r ../pr/pull-request.zip ./*
- uses: actions/upload-artifact@v3
with:
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ node_modules
.yarn
.pnp.cjs
.pnp.loader.mjs
# project build
build
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1 +1,13 @@
# Ubiquibot-logging App

Frontend app that displays [ubiquibot](https://github.com/ubiquity/ubiquibot) logs for debug purposes.

## How to start a dev server
```
yarn start
```

## How to build for production
```
yarn build:prod
```
9 changes: 0 additions & 9 deletions _worker.ts

This file was deleted.

26 changes: 26 additions & 0 deletions esbuild/esbuild-config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import esbuild from 'esbuild';

const config: esbuild.BuildOptions = {
sourcemap: false,
entryPoints: [
'scripts/constants/index.ts',
'scripts/helpers/utils.ts',
'scripts/index.ts',
'styles/index.css',
'index.html',
],
bundle: true,
minify: false,
loader: {
".png": "dataurl",
".woff": "dataurl",
".woff2": "dataurl",
".eot": "dataurl",
".ttf": "dataurl",
".svg": "dataurl",
".html": "copy",
},
outdir: "build",
};

export default config;
11 changes: 11 additions & 0 deletions esbuild/esbuild.dev.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import esbuild from "esbuild";

import config from './esbuild-config';

async function build() {
const context = await esbuild.context(config);
await context.serve({servedir: 'build'});
console.log('Server listening on http://localhost:8000/');
}

build();
5 changes: 5 additions & 0 deletions esbuild/esbuild.prod.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import esbuild from 'esbuild';

import config from "./esbuild-config";

esbuild.build(config);
4 changes: 0 additions & 4 deletions index.ts

This file was deleted.

7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@
"author": "Ubiquity DAO",
"license": "MIT",
"engines": {
"node": ">=v20.8.0"
"node": ">=v18.0.0"
},
"scripts": {
"build": "tsc && tsx ./scripts/esbuild.ts",
"build:prod": "tsx ./esbuild/esbuild.prod.ts",
"format": "run-s format:prettier format:lint",
"format:lint": "eslint --fix .",
"format:prettier": "prettier --write ."
"format:prettier": "prettier --write .",
"start": "tsx ./esbuild/esbuild.dev.ts"
},
"devDependencies": {
"@cloudflare/workers-types": "^3.2.0",
Expand Down
19 changes: 0 additions & 19 deletions scripts/esbuild-config.ts

This file was deleted.

3 changes: 0 additions & 3 deletions scripts/esbuild.ts

This file was deleted.

15 changes: 0 additions & 15 deletions scripts/tsconfig.json

This file was deleted.

9 changes: 0 additions & 9 deletions static/index.html

This file was deleted.

4 changes: 2 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"module": "ESNext",
"moduleResolution": "Node",
"types": ["@cloudflare/workers-types", "node"],
"outDir": "scripts/out"
"outDir": "build"
},
"include": ["./_worker.ts", "./src", "./types", "./scripts", "./index.ts"]
"include": ["./types", "./scripts"]
}
1 change: 0 additions & 1 deletion types/global.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
export interface Env {
ASSETS: Fetcher;
SUPABASE_KEY: string;
SUPABASE_URL: string;
}

1 comment on commit 0517dd0

@ubiquibot
Copy link

@ubiquibot ubiquibot bot commented on 0517dd0 Oct 15, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.