Skip to content

Commit 96ac129

Browse files
lelemmgithub-actions[bot]autofix-ci[bot]
authored
🐛 Fix Service Worker: New hash every build (#5928)
* 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] <github-actions[bot]@users.noreply.github.com> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
1 parent 328dfae commit 96ac129

3 files changed

Lines changed: 11 additions & 3 deletions

File tree

packages/plugins-service/bin/build-service-worker

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ if [ $NODE_ENV == 'development' ]; then
1919
ln -snf "$ROOT"/../dist/ "$DESKTOP_DIR"/service-worker
2020
fi
2121

22-
yarn vite build --config ../vite.config.ts --mode $NODE_ENV $VITE_ARGS
22+
yarn vite build --config ../vite.config.mts --mode $NODE_ENV $VITE_ARGS
2323

2424
if [ $NODE_ENV == 'production' ]; then
2525
# In production, just copy the built files
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ import path from 'path';
33

44
import { defineConfig } from 'vite';
55

6-
// eslint-disable-next-line import/no-default-export
76
export default defineConfig(({ mode }) => {
87
const isDev = mode === 'development';
98
const outDir = path.resolve(__dirname, 'dist');
9+
const buildHash = Date.now().toString(36);
1010

1111
return {
1212
mode,
@@ -18,7 +18,8 @@ export default defineConfig(({ mode }) => {
1818
entry: path.resolve(__dirname, 'src/plugin-service-worker.ts'),
1919
name: 'plugin_sw',
2020
formats: ['iife'],
21-
fileName: () => (isDev ? 'plugin-sw.dev.js' : 'plugin-sw.[hash].js'),
21+
fileName: () =>
22+
isDev ? `plugin-sw.dev.js` : `plugin-sw.${buildHash}.js`,
2223
},
2324
sourcemap: true,
2425
minify: isDev ? false : 'terser',

upcoming-release-notes/5928.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
category: Bugfix
3+
authors: [lelemm]
4+
---
5+
6+
Fix service worker to generate a new hash with every build for better caching.
7+

0 commit comments

Comments
 (0)