vite-pwa / docs

Documentation: PWA integrations for Vite and the ecosystem
https://vite-pwa-org.netlify.app/
MIT License
196 stars 42 forks source link

Create manifest.webmanifest in a sub directory of public #143

Open rafaelragib opened 3 months ago

rafaelragib commented 3 months ago

Greetings,

Firstly, I want to express my gratitude for the outstanding plugin you've developed. It has greatly enhanced my project's functionality.

Issue Overview:

I've encountered a challenge while utilizing the vite-pwa nuxt 3 plugin within my project. In my project's public folder, I have a subdirectory designated for displaying various assets. However, my reverse proxy setup is configured to deny access to all other subdirectories except this designated one. Upon running the Nuxt build process, the plugin generates the following output structure:

While I've successfully managed to configure the service worker (sw.js) and the Workbox file (workbox.js) to be served from the subdirectory by incorporating the following configuration in nuxt.config.js:

workbox: {
  swDest: '/public/subdirectory/sw.js'
}

However, the challenge arises when attempting to automatically generate the manifest.webmanifest file within the subdirectory during the manifest generation process facilitated by the plugin. I am unable to locate any configuration options within the plugin's documentation that would allow me to specify the output directory for the manifest file. Any sort of guidance or assistance in resolving this issue would be really helpful.

userquin commented 3 months ago

Dont change web manifest and sw location, the sw scope cannot be outside the subfolder (you will need to add service-worker-allowed: / http header or similar). The icons can be in any subfolder.

rafaelragib commented 3 months ago

all of the files (nuxt script, icons, assets) are in the subdirectory file. I don't think it will be an issue to serve it from the subdirectory.

userquin commented 3 months ago

The .output/public folder is your app's root context, Vite/Nuxt will copy your public folder assets to that folder (preserving subfolders structure): the sw is under subdirectory path. The sw.js request is <base>/subdirectory/sw.js, the browser will prevent that sw to be installed with scope <base>