Skip to content

Commit c281a87

Browse files
authored
fix(path): use dynamic base path for static assets in HEIC and Flash previews (#149)
1 parent 961bf23 commit c281a87

File tree

3 files changed

+83
-8
lines changed

3 files changed

+83
-8
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
"start": "vite",
2828
"dev": "vite --force",
2929
"build": "vite build",
30-
"build:lite": "export VITE_LITE=true && vite build",
30+
"build:lite": "cross-env VITE_LITE=true vite build",
3131
"serve": "vite preview",
3232
"prepare": "husky",
3333
"format": "prettier --ignore-path .gitignore -w \"src/**/*.{js,ts,json,css,tsx,jsx}\""
@@ -44,6 +44,7 @@
4444
"@types/sha256": "^0.2.2",
4545
"@types/streamsaver": "^2.0.5",
4646
"@vitejs/plugin-legacy": "^6.1.1",
47+
"cross-env": "^7.0.3",
4748
"husky": "^9.0.0",
4849
"lint-staged": "^16.0.0",
4950
"mermaid": "^11.9.0",

pnpm-lock.yaml

Lines changed: 76 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/hooks/useCDN.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { joinBase } from "~/utils"
2+
import packageJson from "../../package.json"
23

34
export const useCDN = () => {
45
const static_path = joinBase("static")
@@ -31,29 +32,26 @@ export const useCDN = () => {
3132
}
3233

3334
const ruffleJSPath = () => {
34-
// ruffle is not available on cnpm white list
3535
return import.meta.env.VITE_LITE === "true"
36-
? "https://res.oplist.org/ruffle/ruffle.js"
36+
? npm(packageJson.name, packageJson.version, "dist/static/ruffle/ruffle.js")
3737
: `${static_path}/ruffle/ruffle.js`
3838
}
3939

4040
const libHeifPath = () => {
41-
// libheif-js is not available on cnpm white list
4241
return import.meta.env.VITE_LITE === "true"
43-
? "https://res.oplist.org/libheif"
42+
? npm(packageJson.name, packageJson.version, "dist/static/libheif")
4443
: `${static_path}/libheif`
4544
}
4645

4746
const libAssPath = () => {
48-
// libass-wasm is not available on cnpm white list
4947
return import.meta.env.VITE_LITE === "true"
50-
? "https://res.oplist.org/libass-wasm"
48+
? npm(packageJson.name, packageJson.version, "dist/static/libass-wasm")
5149
: `${static_path}/libass-wasm`
5250
}
5351

5452
const fontsPath = () => {
5553
return import.meta.env.VITE_LITE === "true"
56-
? "https://res.oplist.org/fonts"
54+
? npm(packageJson.name, packageJson.version, "dist/static/fonts")
5755
: `${static_path}/fonts`
5856
}
5957

0 commit comments

Comments
 (0)