From 96ac1292f93e0fb7a1a94fd55bcafe8328373492 Mon Sep 17 00:00:00 2001 From: lelemm Date: Wed, 15 Oct 2025 13:11:54 -0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Fix=20Service=20Worker:=20New=20?= =?UTF-8?q?hash=20every=20build=20(#5928)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * New hash every build * Add release notes for PR #5928 * trigger actions * Changed from TS to MTS * [autofix.ci] apply automated fixes * [autofix.ci] apply automated fixes (attempt 2/3) --------- Co-authored-by: github-actions[bot] Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> --- packages/plugins-service/bin/build-service-worker | 2 +- .../plugins-service/{vite.config.ts => vite.config.mts} | 5 +++-- upcoming-release-notes/5928.md | 7 +++++++ 3 files changed, 11 insertions(+), 3 deletions(-) rename packages/plugins-service/{vite.config.ts => vite.config.mts} (85%) create mode 100644 upcoming-release-notes/5928.md 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. +