BuilderIO / partytown

Relocate resource intensive third-party scripts off of the main thread and into a web worker. 🎉
https://partytown.builder.io
MIT License
12.98k stars 429 forks source link

Enable running Partytown on a subdirectory #17

Closed ewagstaff closed 2 years ago

ewagstaff commented 2 years ago

I'm able to get Partytown running on my GatsbyJS project in dev! All the proxytown requests are appearing in my network tab.

However, when I try to deploy my project to its live URL, I noticed Partytown's service worker appears to try to install directly to the domain root and fails. In our setup, we do not control what files are added to our domain root, we only control the /projects path of our domain, so ideally there could be some option passed into the Partytown config that would set the scope that the service worker should target.

Forgive me if that's already an option that I'm not seeing.

adamdbradley commented 2 years ago

Good idea. In a working branch I've added the lib property to the config. So in a vanilla example, you could use it like:

partytown = {
  lib: "/some-other-directory/"
}
adamdbradley commented 2 years ago

https://github.com/BuilderIO/partytown/commit/3bdb5f72aa32fba5ab85d7af9b2734ba6d354960