Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: CI

on:
push:
branches: [main]
pull_request:

jobs:
check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 22
cache: npm
- run: npm ci
- run: npm run typecheck
- run: npm run lint
- run: npm test
44 changes: 44 additions & 0 deletions .github/workflows/pages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: GitHub Pages

on:
push:
branches: [main]
workflow_dispatch:

permissions:
contents: read
pages: write
id-token: write

concurrency:
group: pages
cancel-in-progress: true

jobs:
build:
runs-on: ubuntu-latest
env:
VITE_BASE: /convert-everything-studio/
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 22
cache: npm
- run: npm ci
- run: npm run build
- run: cp dist/index.html dist/404.html
- uses: actions/configure-pages@v5
- uses: actions/upload-pages-artifact@v3
with:
path: dist

deploy:
needs: build
runs-on: ubuntu-latest
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- id: deployment
uses: actions/deploy-pages@v4
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

**Website:** https://convert-everything-preview.vercel.app

Same app, production Vercel hostname: https://convert-everything-one.vercel.app
Source: https://github.com/heyandromeda/convert-everything-studio
GitHub Pages (after this workflow runs on `main`): https://heyandromeda.github.io/convert-everything-studio/

This is a website. Open that address in Safari, Chrome, or Firefox. There is no app to install and no App Store listing. On an iPhone, use Safari. Share → Add to Home Screen only saves a shortcut to this same website.

It converts files in the browser tab. Images, documents, spreadsheets, data files, subtitles, archives, audio and video stay on the device and are converted with JavaScript and WebAssembly. Nothing is uploaded.
Expand Down Expand Up @@ -235,7 +239,11 @@ LIVE_URL=https://convert-everything-preview.vercel.app npx playwright test live-
- Root `vercel.json` (generated from `security-headers.mjs` by `node scripts/write-vercel-config.mjs`; a unit test keeps them in sync) for Git-based Vercel builds.
- The CSP is also embedded as a `<meta>` tag, so it applies even on hosts that ignore header files.

**Vercel (current preview host):** `npm run deploy:preview` builds locally, uploads a preview deployment with the Vercel CLI (after `vercel login` and `vercel link`), and points the stable preview address at that deployment: https://convert-everything-preview.vercel.app. It does not publish a production release. The project has Vercel Authentication and the preview feedback toolbar turned off: the toolbar injects a third-party script, which the e2e cross-origin guard flags.
**Vercel:** `npm run deploy:preview` builds locally, uploads a preview deployment with the Vercel CLI (after `vercel login` and `vercel link`), and points the stable preview address at that deployment: https://convert-everything-preview.vercel.app. Production on this Vercel team is https://convert-everything-one.vercel.app (the shorter `convert-everything.vercel.app` name is already taken). The project has Vercel Authentication and the preview feedback toolbar turned off: the toolbar injects a third-party script, which the e2e cross-origin guard flags.

**GitHub Pages:** `.github/workflows/pages.yml` builds with `VITE_BASE=/convert-everything-studio/` and publishes to https://heyandromeda.github.io/convert-everything-studio/ on pushes to `main`. GitHub does not send `dist/_headers`; the CSP meta tag still applies.

**GitHub CI:** `.github/workflows/ci.yml` runs typecheck, lint, and unit tests on pull requests and on `main`.

`netlify.toml` configures Git-based Netlify builds (`npm run build`, publish `dist`). No server-side code or functions exist in this project.

Expand Down
8 changes: 8 additions & 0 deletions tests/unit/registry.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,4 +131,12 @@ describe('deployment config', () => {
expect(csp).toContain("connect-src 'self' blob: data:")
expect(csp).not.toMatch(/https?:/)
})

it('Vite base comes from VITE_BASE so GitHub Pages can live under /convert-everything-studio/', async () => {
const { readFileSync } = await import('node:fs')
const src = readFileSync(new URL('../../vite.config.ts', import.meta.url), 'utf8')
expect(src).toContain("process.env.VITE_BASE")
expect(src).toContain('const base')
expect(src).toContain('withBase')
})
})
21 changes: 13 additions & 8 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ import { defineConfig, type Plugin } from 'vite'
import { VitePWA } from 'vite-plugin-pwa'
import { CSP, SECURITY_HEADERS, vercelConfig } from './security-headers.mjs'

/** Root-relative base. GitHub Pages uses `/convert-everything-studio/`; Vercel stays `/`. */
const base = (process.env.VITE_BASE || '/').replace(/\/?$/, '/')
const withBase = (path: string) => `${base}${path.replace(/^\//, '')}`

/** Injects the CSP meta tag and writes host header files (Netlify `_headers`, `vercel.json`). */
function securityHeaders(): Plugin {
return {
Expand All @@ -23,6 +27,7 @@ function securityHeaders(): Plugin {
}

export default defineConfig({
base,
plugins: [
react(),
tailwindcss(),
Expand All @@ -38,12 +43,12 @@ export default defineConfig({
theme_color: '#ffffff',
background_color: '#ffffff',
display: 'standalone',
start_url: '/',
scope: '/',
start_url: withBase(''),
scope: withBase(''),
icons: [
{ src: '/icons/icon-192.png', sizes: '192x192', type: 'image/png' },
{ src: '/icons/icon-512.png', sizes: '512x512', type: 'image/png' },
{ src: '/icons/icon-maskable-512.png', sizes: '512x512', type: 'image/png', purpose: 'maskable' },
{ src: withBase('icons/icon-192.png'), sizes: '192x192', type: 'image/png' },
{ src: withBase('icons/icon-512.png'), sizes: '512x512', type: 'image/png' },
{ src: withBase('icons/icon-maskable-512.png'), sizes: '512x512', type: 'image/png', purpose: 'maskable' },
],
},
workbox: {
Expand All @@ -58,16 +63,16 @@ export default defineConfig({
warnings: [],
}),
],
navigateFallback: '/index.html',
navigateFallback: withBase('index.html'),
runtimeCaching: [
{
urlPattern: ({ url }) => url.pathname.startsWith('/vendor/'),
urlPattern: ({ url }) => url.pathname.includes('/vendor/'),
handler: 'CacheFirst',
options: { cacheName: 'ce-engines', expiration: { maxEntries: 400 }, cacheableResponse: { statuses: [0, 200] } },
},
{
// Hashed build assets that were too large to precache.
urlPattern: ({ url }) => url.pathname.startsWith('/assets/'),
urlPattern: ({ url }) => url.pathname.includes('/assets/'),
handler: 'CacheFirst',
options: { cacheName: 'ce-engines-assets', expiration: { maxEntries: 200 }, cacheableResponse: { statuses: [0, 200] } },
},
Expand Down
Loading