How to enable pwa with vite-plugin-pwa

Viewed 45

what do I need to prescribe in order to enable pwa?

when i do "Analyze page load", I get information that pwa is disabled.

vite.config.js

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import { VitePWA } from 'vite-plugin-pwa'

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    vue(),
    VitePWA({
      registerType: 'autoUpdate',
      injectRegister: 'auto',
    }),
  ],
})
1 Answers

Are you running in dev by any chance?

If you want to check it in dev, add the devOptions option to the plugin configuration

import { VitePWA } from 'vite-plugin-pwa'
export default defineConfig({
  plugins: [
    VitePWA({
      registerType: 'autoUpdate',
      devOptions: {
        enabled: true
      }
    })
  ]
})
Related