Skip to content

Commit 2f013f9

Browse files
author
y
authored
use vite to build and process project files
1 parent 40a2002 commit 2f013f9

File tree

5 files changed

+1444
-28
lines changed

5 files changed

+1444
-28
lines changed

.github/workflows/pages.yml

Lines changed: 19 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -21,40 +21,31 @@ jobs:
2121
- name: Checkout repository
2222
uses: actions/checkout@v4
2323

24-
- name: Setup GitHub Pages
25-
uses: actions/configure-pages@v4
26-
27-
- name: Prepare build folder
28-
run: |
29-
rm -rf build
30-
mkdir -p build
31-
cp -r src/* build/
32-
33-
- name: Inject SHA and asset list into service worker
34-
run: |
35-
SHA=$(git rev-parse --short HEAD)
36-
echo "SHA: $SHA"
24+
- name: Setup Node.js
25+
uses: actions/setup-node@v4
26+
with:
27+
node-version: 20
28+
cache: 'npm'
3729

38-
echo "Generating asset list..."
39-
find build -type f ! -name service-worker.js \
40-
| sed 's|^build||; s| |%20|g' \
41-
| jq -R . | jq -s . > asset-list.json
30+
- name: Install dependencies
31+
run: npm ci
4232

43-
echo "Generated asset list:"
44-
cat asset-list.json
33+
- name: Get short SHA
34+
id: vars
35+
run: echo "sha=$(git rev-parse --short HEAD)" >> "$GITHUB_OUTPUT"
4536

46-
echo "Injecting SHA into template..."
47-
sed "s|__BUILD_SHA__|$SHA|g" src/service-worker.js > build/service-worker.tmp.js
37+
- name: Build project
38+
run: |
39+
echo "VITE_COMMIT_SHA=${{ steps.vars.outputs.sha }}" >> .env
40+
npm run build
4841
49-
echo "Injecting asset list..."
50-
SERVICE_WORKER_CONTENT=$(cat build/service-worker.tmp.js)
51-
ASSET_LIST_JSON=$(cat asset-list.json)
52-
echo "${SERVICE_WORKER_CONTENT/__ASSETS__/${ASSET_LIST_JSON}}" > build/service-worker.js
42+
- name: Setup GitHub Pages
43+
uses: actions/configure-pages@v4
5344

5445
- name: Upload build artifact
55-
uses: actions/upload-pages-artifact@v3
46+
uses: actions/upload-pages-artifact@v4
5647
with:
57-
path: './build'
48+
path: './dist'
5849

5950
- name: Deploy to GitHub Pages
60-
uses: actions/deploy-pages@v4
51+
uses: actions/deploy-pages@v3

.gitignore

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
yarn-debug.log*
6+
yarn-error.log*
7+
pnpm-debug.log*
8+
lerna-debug.log*
9+
10+
node_modules
11+
dist
12+
dist-ssr
13+
*.local
14+
15+
# Editor directories and files
16+
.vscode/*
17+
!.vscode/extensions.json
18+
.idea
19+
.DS_Store
20+
*.suo
21+
*.ntvs*
22+
*.njsproj
23+
*.sln
24+
*.sw?

0 commit comments

Comments
 (0)