mirror of
https://github.com/coder/coder.git
synced 2026-06-02 20:48:20 +00:00
feat(site): add webpush notification serviceworker (#17123)
* Improves tests for webpush notifications
* Sets subscriber correctly in web push payload (without this,
notifications do not work in Safari)
* NOTE: for now, I'm using the Coder Access URL. Some push messaging
service don't like it when you use a non-HTTPS URL, so dropping a warn
log about this.
* Adds a service worker and context for push notifications
* Adds a button beside "Inbox" to enable / disable push notifications
Notes:
* ✅ Tested in in Firefox and Safari, and Chrome.
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import * as path from "node:path";
|
||||
import react from "@vitejs/plugin-react";
|
||||
import { buildSync } from "esbuild";
|
||||
import { visualizer } from "rollup-plugin-visualizer";
|
||||
import { type PluginOption, defineConfig } from "vite";
|
||||
import checker from "vite-plugin-checker";
|
||||
@@ -28,6 +29,19 @@ export default defineConfig({
|
||||
emptyOutDir: false,
|
||||
// 'hidden' works like true except that the corresponding sourcemap comments in the bundled files are suppressed
|
||||
sourcemap: "hidden",
|
||||
rollupOptions: {
|
||||
input: {
|
||||
index: path.resolve(__dirname, "./index.html"),
|
||||
serviceWorker: path.resolve(__dirname, "./src/serviceWorker.ts"),
|
||||
},
|
||||
output: {
|
||||
entryFileNames: (chunkInfo) => {
|
||||
return chunkInfo.name === "serviceWorker"
|
||||
? "[name].js"
|
||||
: "assets/[name]-[hash].js";
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
define: {
|
||||
"process.env": {
|
||||
@@ -89,6 +103,10 @@ export default defineConfig({
|
||||
target: process.env.CODER_HOST || "http://localhost:3000",
|
||||
secure: process.env.NODE_ENV === "production",
|
||||
},
|
||||
"/serviceWorker.js": {
|
||||
target: process.env.CODER_HOST || "http://localhost:3000",
|
||||
secure: process.env.NODE_ENV === "production",
|
||||
},
|
||||
},
|
||||
allowedHosts: true,
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user