Disable bundling of specific file(s) for vitejs svelte project

Viewed 44

I'm trying to add push notifications to my svelte site using Firebase/Google Cloud Messaging (FCM), and a service worker JS file needs to exist at the absolute path: https://example.com/firebase-messaging-sw.js . However, Vitejs is bundling this with the other svelte/js code in my project. I can manually place the file there, but then it won't be transpiled. Aka these imports here won't work in the file:

import { initializeApp } from "firebase/app";
import { getMessaging } from "firebase/messaging/sw";

So how do I tell Vite not to bundle this file and have it output at the root dir? Alternatively, I saw there might be a way to pass a service worker differently, if that removes the need for the js file please let me know roughly how it's done. Thank you.

0 Answers
Related