Skip to content

Commit

Permalink
refactor into an SPA and library
Browse files Browse the repository at this point in the history
  • Loading branch information
tuner committed Oct 2, 2024
1 parent 098fc26 commit 0dac88f
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 13 deletions.
13 changes: 6 additions & 7 deletions .github/workflows/github-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ name: Deploy static content to Pages
on:
# Runs on pushes targeting the default branch
push:
branches: ['main']
branches: ["main"]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
Expand All @@ -17,7 +17,7 @@ permissions:

# Allow one concurrent deployment
concurrency:
group: 'pages'
group: "pages"
cancel-in-progress: true

jobs:
Expand All @@ -34,20 +34,19 @@ jobs:
uses: actions/setup-node@v4
with:
node-version: 20
cache: 'npm'
cache: "npm"
- name: Install dependencies
run: npm ci
- name: Build
run: npm run build
run: npm run build:app
- name: Copy data folder to dist
run: cp -r ./data ./dist/data
run: cp -r ./data ./dist/app/data
- name: Setup Pages
uses: actions/configure-pages@v4
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
# Upload dist folder
path: './dist'
path: "./dist/app"
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"type": "module",
"scripts": {
"dev": "vite",
"build": "tsc && vite build",
"build:app": "tsc && vite build",
"build:lib": "tsc && vite build --mode lib",
"preview": "vite preview"
},
"devDependencies": {
Expand Down
4 changes: 4 additions & 0 deletions src/gui/lib.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import "../../style.css";
import { setupGui } from "./gui.js";

export { setupGui };
28 changes: 23 additions & 5 deletions vite.config.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,26 @@
import { defineConfig } from "vite";

export default defineConfig({
base: "",
build: {
sourcemap: true,
},
export default defineConfig(({ command, mode }) => {
if (command === "build" && mode === "lib") {
return {
build: {
lib: {
entry: "./src/gui/lib.ts",
name: "jellyfish",
fileName: (format) => `jellyfish.${format}.js`,
formats: ["es", "umd"],
},
outDir: "dist/lib",
cssCodeSplit: true,
},
};
}

return {
base: "",
build: {
sourcemap: true,
outDir: "dist/app",
},
};
});

0 comments on commit 0dac88f

Please sign in to comment.