diff --git a/.github/workflows/github-pages.yml b/.github/workflows/github-pages.yml index b8c9c09..475af2d 100644 --- a/.github/workflows/github-pages.yml +++ b/.github/workflows/github-pages.yml @@ -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: @@ -17,7 +17,7 @@ permissions: # Allow one concurrent deployment concurrency: - group: 'pages' + group: "pages" cancel-in-progress: true jobs: @@ -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 diff --git a/package.json b/package.json index c6ecab6..14a01ad 100644 --- a/package.json +++ b/package.json @@ -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": { diff --git a/src/gui/lib.ts b/src/gui/lib.ts new file mode 100644 index 0000000..85e1292 --- /dev/null +++ b/src/gui/lib.ts @@ -0,0 +1,4 @@ +import "../../style.css"; +import { setupGui } from "./gui.js"; + +export { setupGui }; diff --git a/vite.config.js b/vite.config.js index a2b7fa1..57ab21d 100644 --- a/vite.config.js +++ b/vite.config.js @@ -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", + }, + }; });