Skip to content

Upload prompt not working correctly when adding base url #859

@ghbishal

Description

@ghbishal
Image

The above image is the basic setup i did and i just updated my vite.config.ts to this below,

Basically i added prefix path so my base url is http://localhost:4173/mobile

The problem is, When I am not using the base url and when I reload page I get the reload prompt like the picture below , But when i am using baseUrl and I do not get the reload prompt, It's updated directly without any prompt. and after I manually press update button on the top right and reload the page i get the prompt saying App ready to work offline

Image
import { VitePWA } from "vite-plugin-pwa";
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";

const PATH_PREFIX = "mobile";

// https://vitejs.dev/config/
export default defineConfig({
  base: `/${PATH_PREFIX}`,
  plugins: [
    react(),
    VitePWA({
      strategies: "injectManifest",
      srcDir: "src",
      filename: "sw.ts",
      registerType: "prompt",
      injectRegister: false,

      manifest: {
        name: "pwa-inject-manifest-prompt",
        short_name: "pwa-inject-manifest-prompt",
        description: "pwa-inject-manifest-prompt",
        theme_color: "#ffffff",

        icons: [
          {
            src: "pwa-64x64.png",
            sizes: "64x64",
            type: "image/png",
          },
          {
            src: "pwa-192x192.png",
            sizes: "192x192",
            type: "image/png",
          },
          {
            src: "pwa-512x512.png",
            sizes: "512x512",
            type: "image/png",
          },
          {
            src: "maskable-icon-512x512.png",
            sizes: "512x512",
            type: "image/png",
            purpose: "maskable",
          },
        ],
      },

      workbox: {
        cleanupOutdatedCaches: true,
      },

      injectManifest: {
        globPatterns: ["**/*.{js,css,html,svg,png,ico}"],
      },

      devOptions: {
        enabled: true,
        navigateFallback: "index.html",
        suppressWarnings: true,
        type: "module",
      },
    }),
  ],
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions