diff --git a/packages/plugins-service/bin/build-service-worker b/packages/plugins-service/bin/build-service-worker index 9cffbdd32e..8f378fc98a 100755 --- a/packages/plugins-service/bin/build-service-worker +++ b/packages/plugins-service/bin/build-service-worker @@ -19,7 +19,7 @@ if [ $NODE_ENV == 'development' ]; then ln -snf "$ROOT"/../dist/ "$DESKTOP_DIR"/service-worker fi -yarn vite build --config ../vite.config.ts --mode $NODE_ENV $VITE_ARGS +yarn vite build --config ../vite.config.mts --mode $NODE_ENV $VITE_ARGS if [ $NODE_ENV == 'production' ]; then # In production, just copy the built files diff --git a/packages/plugins-service/vite.config.ts b/packages/plugins-service/vite.config.mts similarity index 85% rename from packages/plugins-service/vite.config.ts rename to packages/plugins-service/vite.config.mts index 1d32177b34..1eedc93a04 100644 --- a/packages/plugins-service/vite.config.ts +++ b/packages/plugins-service/vite.config.mts @@ -3,10 +3,10 @@ import path from 'path'; import { defineConfig } from 'vite'; -// eslint-disable-next-line import/no-default-export export default defineConfig(({ mode }) => { const isDev = mode === 'development'; const outDir = path.resolve(__dirname, 'dist'); + const buildHash = Date.now().toString(36); return { mode, @@ -18,7 +18,8 @@ export default defineConfig(({ mode }) => { entry: path.resolve(__dirname, 'src/plugin-service-worker.ts'), name: 'plugin_sw', formats: ['iife'], - fileName: () => (isDev ? 'plugin-sw.dev.js' : 'plugin-sw.[hash].js'), + fileName: () => + isDev ? `plugin-sw.dev.js` : `plugin-sw.${buildHash}.js`, }, sourcemap: true, minify: isDev ? false : 'terser', diff --git a/upcoming-release-notes/5928.md b/upcoming-release-notes/5928.md new file mode 100644 index 0000000000..05d7ecfd52 --- /dev/null +++ b/upcoming-release-notes/5928.md @@ -0,0 +1,7 @@ +--- +category: Bugfix +authors: [lelemm] +--- + +Fix service worker to generate a new hash with every build for better caching. +