Skip to content

Commit ae445da

Browse files
authored
refactor!: improve CDN resource management (#144)
* Add `useCDN` hook for better management of CDN resources. * Bundle CDN resources (Monaco Editor, KaTeX, Mermaid, Ruffle, etc.) using `vite-plugin-static-copy` into the dist, which can be beneficial for environments with network problems. * Add `VITE_LITE` environment for conditional lite version compilation, removing the need for a separate lite branch. BREAKING CHANGE: The lite branch is no longer needed.
1 parent 36502b9 commit ae445da

29 files changed

+1276
-21375
lines changed

.github/workflows/build_release.yml

Lines changed: 17 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -132,41 +132,25 @@ jobs:
132132
CROWDIN_PROJECT_ID: ${{ secrets.CROWDIN_PROJECT_ID }}
133133
CROWDIN_PERSONAL_TOKEN: ${{ secrets.CROWDIN_PERSONAL_TOKEN }}
134134

135-
- name: Checkout lite version code
136-
uses: actions/checkout@v4
137-
with:
138-
ref: lite
139-
path: lite
140-
fetch-depth: 0
141-
submodules: recursive
142-
143-
- name: Setup CI Bot
144-
if: github.event_name == 'workflow_dispatch'
145-
working-directory: ./lite
135+
- name: Move regular build
146136
run: |
147-
git config user.name "The OpenList Bot"
148-
git config user.email "[email protected]"
149-
150-
- name: Update package.json and commit
151-
if: github.event_name == 'workflow_dispatch'
152-
working-directory: ./lite
153-
run: |
154-
jq --arg version "${{ steps.semver.outputs.version }}" '.version = $version' package.json > package.json.tmp && mv package.json.tmp package.json
155-
git add package.json
156-
git commit -S -m "chore: release v${{ steps.semver.outputs.version }}" --no-verify
157-
git push
137+
mkdir -p regular-dist
138+
mv dist/* regular-dist/
158139
159140
- name: Build Lite Release
160141
run: |
161-
rm -rf .git
162-
cp -r ../.git .git
163142
chmod +x build.sh
164143
./build.sh --release --compress --lite
165-
working-directory: ./lite
166144
env:
167145
CROWDIN_PROJECT_ID: ${{ secrets.CROWDIN_PROJECT_ID }}
168146
CROWDIN_PERSONAL_TOKEN: ${{ secrets.CROWDIN_PERSONAL_TOKEN }}
169147

148+
- name: Move lite build and restore regular build
149+
run: |
150+
mkdir -p lite-dist
151+
mv dist/* lite-dist/
152+
mv regular-dist/* dist/
153+
170154
- name: Upload Release Assets
171155
run: |
172156
# Delete local tag, or gh cli will complain about it.
@@ -176,25 +160,28 @@ jobs:
176160
--notes-file "${{ github.workspace }}-CHANGELOG.txt" \
177161
--prerelease=${{ steps.check_pre_release.outputs.is_pre_release }} \
178162
${{ steps.get_current_tag.outputs.current_tag }} \
179-
dist/openlist-frontend-dist-v*.tar.gz lite/dist/openlist-frontend-dist-lite-v*.tar.gz dist/i18n.tar.gz
163+
dist/openlist-frontend-dist-v*.tar.gz lite-dist/openlist-frontend-dist-lite-v*.tar.gz dist/i18n.tar.gz
180164
env:
181165
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
182166

183-
- name: Publish npm
167+
- name: Prepare for npm
184168
run: |
185-
echo "//registry.npmjs.org/:_authToken=${NODE_AUTH_TOKEN}" > ~/.npmrc
186169
# Delete the generated dist tarball
187170
rm -f dist/openlist-frontend-dist-v*.tar.gz
188-
rm -f lite/dist/openlist-frontend-dist-lite-v*.tar.gz
171+
rm -f lite-dist/openlist-frontend-dist-lite-v*.tar.gz
189172
# Copy the lite version
190173
mkdir dist/lite
191-
cp -r lite/dist/. dist/lite/
174+
cp -r lite-dist/. dist/lite/
192175
193176
if ! jq -e '.name and .version' package.json > /dev/null; then
194177
echo "Error: Invalid package.json"
195178
exit 1
196179
fi
197180
181+
- name: Publish npm
182+
run: |
183+
echo "//registry.npmjs.org/:_authToken=${NODE_AUTH_TOKEN}" > ~/.npmrc
184+
198185
if [ -z "${{ secrets.NPM_TOKEN }}" ]; then
199186
echo "NPM_TOKEN not set, performing dry run"
200187
pnpm publish --dry-run --no-git-checks --access public

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,22 @@
1111
You can use [the build script](./build.sh).
1212

1313
```plaintext
14-
Usage: ./build.sh [--dev|--release] [--compress|--no-compress] [--enforce-tag]
14+
Usage: ./build.sh [--dev|--release] [--compress|--no-compress] [--enforce-tag] [--skip-i18n] [--lite]
1515
1616
Options (will overwrite environment setting):
1717
--dev Build development version
1818
--release Build release version (will check if git tag match package.json version)
1919
--compress Create compressed archive
2020
--no-compress Skip compression
2121
--enforce-tag Force git tag requirement for both dev and release builds
22+
--skip-i18n Skip i18n build step
23+
--lite Build lite version
2224
2325
Environment variables:
2426
OPENLIST_FRONTEND_BUILD_MODE=dev|release (default: dev)
2527
OPENLIST_FRONTEND_BUILD_COMPRESS=true|false (default: false)
2628
OPENLIST_FRONTEND_BUILD_ENFORCE_TAG=true|false (default: false)
29+
OPENLIST_FRONTEND_BUILD_SKIP_I18N=true|false (default: false)
2730
```
2831

2932
## LICENSE

build.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ display_help() {
6464
echo " --no-compress Skip compression"
6565
echo " --enforce-tag Force git tag requirement for both dev and release builds"
6666
echo " --skip-i18n Skip i18n build step"
67-
echo " --lite Add -lite suffix to frontend archive name"
67+
echo " --lite Build lite version"
6868
echo ""
6969
echo "Environment variables:"
7070
echo " OPENLIST_FRONTEND_BUILD_MODE=dev|release (default: dev)"
@@ -149,7 +149,11 @@ build_project() {
149149
fi
150150

151151
log_step "==== Building project ===="
152-
pnpm build
152+
if [[ "$LITE_FLAG" == "true" ]]; then
153+
pnpm build:lite
154+
else
155+
pnpm build
156+
fi
153157
}
154158

155159
# Fetch i18n files from release if skip-i18n flag is set

index.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
<script>
2929
window.OPENLIST_CONFIG = {
3030
cdn: undefined,
31-
monaco_cdn: undefined,
3231
base_path: undefined,
3332
api: undefined,
3433
main_color: undefined,

package.json

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
"start": "vite",
2828
"dev": "vite --force",
2929
"build": "vite build",
30+
"build:lite": "export VITE_LITE=true && vite build",
3031
"serve": "vite preview",
3132
"prepare": "husky",
3233
"format": "prettier --ignore-path .gitignore -w \"src/**/*.{js,ts,json,css,tsx,jsx}\""
@@ -45,20 +46,22 @@
4546
"@vitejs/plugin-legacy": "^6.1.1",
4647
"husky": "^9.0.0",
4748
"lint-staged": "^16.0.0",
49+
"mermaid": "^11.9.0",
4850
"prettier": "3.6.2",
49-
"rollup-plugin-copy": "^3.5.0",
5051
"terser": "^5.43.1",
5152
"typescript": "^5.8.3",
5253
"vite": "^6.3.5",
5354
"vite-plugin-dynamic-base": "^1.0.0",
54-
"vite-plugin-solid": "^2.11.7"
55+
"vite-plugin-solid": "^2.11.7",
56+
"vite-plugin-static-copy": "^3.1.1"
5557
},
5658
"dependencies": {
5759
"@egjs/view360": "4.0.0-beta.7",
5860
"@github/webauthn-json": "^2.1.1",
5961
"@hope-ui/solid": "0.6.7",
6062
"@monaco-editor/loader": "^1.5.0",
6163
"@pdfslick/solid": "^3.0.0",
64+
"@ruffle-rs/ruffle": "0.2.0-nightly.2025.8.3",
6265
"@solid-primitives/i18n": "^2.2.1",
6366
"@solid-primitives/keyboard": "^1.3.1",
6467
"@solid-primitives/storage": "^1.3.11",
@@ -80,10 +83,13 @@
8083
"hls.js": "^1.6.5",
8184
"ini": "^5.0.0",
8285
"just-once": "^2.2.0",
86+
"katex": "0.16.11",
8387
"libass-wasm": "^4.1.0",
88+
"libheif-js": "^1.19.8",
8489
"lightgallery": "^2.8.3",
8590
"mark.js": "^8.11.1",
8691
"mitt": "^3.0.1",
92+
"monaco-editor": "^0.52.2",
8793
"mpegts.js": "^1.8.0",
8894
"pdfjs-dist": "^5.3.31",
8995
"qrcode": "^1.5.4",

0 commit comments

Comments
 (0)