-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f4f6092
commit d120d34
Showing
14 changed files
with
1,096 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
on: | ||
push: | ||
pull_request: | ||
|
||
name: CI | ||
jobs: | ||
|
||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check out source code | ||
uses: actions/checkout@v4 | ||
- name: Install and build | ||
run: | | ||
npm ci | ||
npm run minify | ||
- name: Upload artifact | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: dist | ||
path: dist/ | ||
|
||
deploy: | ||
needs: build | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: write | ||
steps: | ||
- name: Check out repository | ||
uses: actions/checkout@v4 | ||
- name: Download artifact | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: dist | ||
path: dist/ | ||
- name: Disable Jekyll | ||
run: | | ||
touch dist/.nojekyll | ||
- name: Publish artifact | ||
if: "${{ github.event_name == 'push' && github.event.ref == 'refs/heads/main' }}" | ||
uses: JamesIves/github-pages-deploy-action@releases/v4 | ||
with: | ||
folder: dist/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import * as process from 'node:process'; | ||
import * as esbuild from 'esbuild'; | ||
import metaUrlPlugin from '@chialab/esbuild-plugin-meta-url'; | ||
|
||
const mode = (process.argv[2] ?? 'build'); | ||
const options = { | ||
logLevel: 'info', | ||
plugins: [metaUrlPlugin()], | ||
bundle: true, | ||
loader: { | ||
'.html': 'copy', | ||
'.svg': 'dataurl', | ||
'.ttf': 'file', | ||
'.woff': 'file', | ||
'.woff2': 'file', | ||
'.json': 'file', | ||
'.wasm': 'file', | ||
'.asm.wasm': 'copy', | ||
'.zip': 'file', | ||
}, | ||
external: [ | ||
'fs/promises', // @yowasp/yosys | ||
'node-fetch', // pyodide | ||
], | ||
define: { | ||
'globalThis.IS_PRODUCTION': (mode === 'minify' ? 'true' : 'false'), | ||
}, | ||
target: 'es2021', | ||
format: 'esm', | ||
sourcemap: 'linked', | ||
minify: (mode === 'minify'), | ||
outdir: 'dist', | ||
entryPoints: { | ||
'index': './src/index.html', | ||
'app': './src/app.tsx', | ||
'app.worker': './src/worker.ts', | ||
'editor.worker': 'monaco-editor/esm/vs/editor/editor.worker.js', | ||
'pyodide.asm': 'pyodide/pyodide.asm.wasm', | ||
}, | ||
}; | ||
|
||
if (mode === 'build' || mode === 'minify') { | ||
await esbuild.build(options); | ||
} else if (mode === 'watch') { | ||
const context = await esbuild.context(options); | ||
await context.watch(); | ||
} else if (mode === 'serve') { | ||
const context = await esbuild.context(options); | ||
await context.rebuild(); | ||
await context.watch(); | ||
// Specifying `servedir` is necessary for files built by meta URL plugin to be accessible. | ||
await context.serve({ servedir: 'dist' }); | ||
} else { | ||
console.error(`Usage: ${process.argv0} [build|watch|serve|minify]`); | ||
} |
Oops, something went wrong.