rename service-worker.js back to sw.js to unbreak updating

This commit is contained in:
Bruno Windels 2021-08-23 20:23:38 +02:00
parent 3d6a990c58
commit 54ac5a96ca
3 changed files with 5 additions and 5 deletions

View file

@ -114,8 +114,8 @@ async function build({modernOnly, overrideImports, overrideCss}) {
await buildManifest(assets); await buildManifest(assets);
// all assets have been added, create a hash from all assets name to cache unhashed files like index.html // all assets have been added, create a hash from all assets name to cache unhashed files like index.html
assets.addToHashForAll("index.html", devHtml); assets.addToHashForAll("index.html", devHtml);
let swSource = await fs.readFile(path.join(snowpackOutPath, "service-worker.js"), "utf8"); let swSource = await fs.readFile(path.join(snowpackOutPath, "sw.js"), "utf8");
assets.addToHashForAll("service-worker.js", swSource); assets.addToHashForAll("sw.js", swSource);
const globalHash = assets.hashForAll(); const globalHash = assets.hashForAll();
@ -174,7 +174,7 @@ async function buildHtml(doc, version, baseConfig, globalHash, modernOnly, asset
const configJSON = JSON.stringify(Object.assign({}, baseConfig, { const configJSON = JSON.stringify(Object.assign({}, baseConfig, {
worker: assets.has("worker.js") ? assets.resolve(`worker.js`) : null, worker: assets.has("worker.js") ? assets.resolve(`worker.js`) : null,
downloadSandbox: assets.resolve("download-sandbox.html"), downloadSandbox: assets.resolve("download-sandbox.html"),
serviceWorker: "service-worker.js", serviceWorker: "sw.js",
olm: { olm: {
wasm: assets.resolve("olm.wasm"), wasm: assets.resolve("olm.wasm"),
legacyBundle: assets.resolve("olm_legacy.js"), legacyBundle: assets.resolve("olm_legacy.js"),
@ -342,7 +342,7 @@ async function buildServiceWorker(swSource, version, globalHash, assets) {
swSource = replaceStringInSource("NOTIFICATION_BADGE_ICON", assets.resolve("icon.png")); swSource = replaceStringInSource("NOTIFICATION_BADGE_ICON", assets.resolve("icon.png"));
// service worker should not have a hashed name as it is polled by the browser for updates // service worker should not have a hashed name as it is polled by the browser for updates
await assets.writeUnhashed("service-worker.js", swSource); await assets.writeUnhashed("sw.js", swSource);
} }
async function buildCssBundles(buildFn, themes, assets, mainCssFile = null) { async function buildCssBundles(buildFn, themes, assets, mainCssFile = null) {

View file

@ -26,7 +26,7 @@
downloadSandbox: "assets/download-sandbox.html", downloadSandbox: "assets/download-sandbox.html",
defaultHomeServer: "matrix.org", defaultHomeServer: "matrix.org",
// NOTE: uncomment this if you want the service worker for local development // NOTE: uncomment this if you want the service worker for local development
// serviceWorker: "service-worker.js", // serviceWorker: "sw.js",
// NOTE: provide push config if you want push notifs for local development // NOTE: provide push config if you want push notifs for local development
// see assets/config.json for what the config looks like // see assets/config.json for what the config looks like
// push: {...}, // push: {...},