Skip to content

Commit 44f7f8a

Browse files
committed
ci(github): add GitHub Actions workflow for Pages deployment
1 parent d89e28a commit 44f7f8a

3 files changed

Lines changed: 69 additions & 17 deletions

File tree

.github/workflows/pages.yml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: Deploy Pages
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
workflow_dispatch:
8+
9+
permissions:
10+
contents: read
11+
pages: write
12+
id-token: write
13+
14+
concurrency:
15+
group: pages
16+
cancel-in-progress: true
17+
18+
jobs:
19+
build:
20+
runs-on: ubuntu-latest
21+
22+
steps:
23+
- name: Check out repository
24+
uses: actions/checkout@v5
25+
26+
- name: Set up pnpm
27+
uses: pnpm/action-setup@v4
28+
29+
- name: Set up Node.js
30+
uses: actions/setup-node@v5
31+
with:
32+
node-version: 22
33+
cache: pnpm
34+
35+
- name: Install dependencies
36+
run: pnpm install --frozen-lockfile
37+
38+
- name: Prepare Pages artifact
39+
run: |
40+
mkdir -p _site
41+
cp index.html _site/index.html
42+
cp -R dist _site/dist
43+
44+
- name: Configure Pages
45+
uses: actions/configure-pages@v5
46+
47+
- name: Upload Pages artifact
48+
uses: actions/upload-pages-artifact@v4
49+
with:
50+
path: _site
51+
52+
deploy:
53+
environment:
54+
name: github-pages
55+
url: ${{ steps.deployment.outputs.page_url }}
56+
runs-on: ubuntu-latest
57+
needs: build
58+
59+
steps:
60+
- name: Deploy to GitHub Pages
61+
id: deployment
62+
uses: actions/deploy-pages@v4

index.html

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -494,13 +494,16 @@ <h2>Toolbar</h2>
494494
</template>
495495

496496
<script type="module">
497-
import {
497+
const modulePath = import.meta.env?.DEV
498+
? './src/index.ts'
499+
: './dist/index.js';
500+
const {
498501
AlertsElement,
499502
MenuElement,
500503
TabsElement,
501504
ToolbarElement,
502505
TooltipElement,
503-
} from 'inclusive-elements';
506+
} = await import(modulePath);
504507

505508
customElements.define('ui-menu', MenuElement);
506509
customElements.define('ui-tooltip', TooltipElement);

vite.config.js

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,12 @@
1-
import { resolve } from 'node:path';
21
import { fileURLToPath } from 'node:url';
32
import { defineConfig } from 'vite';
43

5-
const rootDir = fileURLToPath(new URL('.', import.meta.url));
6-
74
export default defineConfig({
8-
resolve: {
9-
alias: {
10-
'inclusive-elements': resolve(rootDir, 'src/index.ts'),
11-
},
12-
},
135
build: {
146
lib: {
15-
entry: resolve(rootDir, 'src/index.ts'),
7+
entry: fileURLToPath(new URL('./src/index.ts', import.meta.url)),
168
formats: ['es'],
17-
},
18-
rollupOptions: {
19-
output: {
20-
entryFileNames: '[name].js',
21-
chunkFileNames: 'chunks/[name]-[hash].js',
22-
},
9+
fileName: 'index',
2310
},
2411
},
2512
});

0 commit comments

Comments
 (0)