mirror of
https://github.com/suitenumerique/meet.git
synced 2026-08-31 12:47:58 +00:00
🐛(frontend) serve MediaPipe assets under a versioned path
The MediaPipe assets were served under /assets, where the cache behavior differs between wasm and js files. As a result, clients could end up with a fresh js loader paired with a stale wasm binary (or vice versa), leaving MediaPipe out of sync. Copy the assets under a versioned route so the URL changes whenever the dependency version bumps. Clients then reload both the js and the wasm together, keeping them in sync.
This commit is contained in:
committed by
aleb_the_flash
parent
41e937c1f1
commit
f3626a2dc6
@@ -1,13 +1,27 @@
|
||||
import { readFileSync } from 'node:fs'
|
||||
import { defineConfig, loadEnv } from 'vite'
|
||||
import react from '@vitejs/plugin-react'
|
||||
import { visualizer } from 'rollup-plugin-visualizer'
|
||||
import svgr from 'vite-plugin-svgr'
|
||||
import { viteStaticCopy } from 'vite-plugin-static-copy'
|
||||
|
||||
const mediapipeVersion: string = JSON.parse(
|
||||
readFileSync(
|
||||
new URL(
|
||||
'./node_modules/@mediapipe/tasks-vision/package.json',
|
||||
import.meta.url
|
||||
),
|
||||
'utf-8'
|
||||
)
|
||||
).version
|
||||
|
||||
// https://vitejs.dev/config/
|
||||
export default defineConfig(({ mode }) => {
|
||||
const env = loadEnv(mode, process.cwd())
|
||||
return {
|
||||
define: {
|
||||
__MEDIAPIPE_VERSION__: JSON.stringify(mediapipeVersion),
|
||||
},
|
||||
plugins: [
|
||||
react(),
|
||||
svgr({
|
||||
@@ -23,7 +37,7 @@ export default defineConfig(({ mode }) => {
|
||||
targets: [
|
||||
{
|
||||
src: 'node_modules/@mediapipe/tasks-vision/wasm/*',
|
||||
dest: 'assets/mediapipe/wasm',
|
||||
dest: `assets/mediapipe/wasm/${mediapipeVersion}`,
|
||||
rename: { stripBase: 4 },
|
||||
},
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user