Coder Social home page Coder Social logo

vite-plugin-pwa's Introduction

vite-plugin-pwa - Zero-config PWA for Vite
Zero-config PWA Framework-agnostic Plugin for Vite

NPM version NPM Downloads Docs & Guides
GitHub stars


๐Ÿš€ Features

  • ๐Ÿ“– Documentation & guides
  • ๐Ÿ‘Œ Zero-Config: sensible built-in default configs for common use cases
  • ๐Ÿ”ฉ Extensible: expose the full ability to customize the behavior of the plugin
  • ๐Ÿฆพ Type Strong: written in TypeScript
  • ๐Ÿ”Œ Offline Support: generate service worker with offline support (via Workbox)
  • โšก Fully tree shakable: auto inject Web App Manifest
  • ๐Ÿ’ฌ Prompt for new content: built-in support for Vanilla JavaScript, Vue 3, React, Svelte, SolidJS and Preact
  • โš™๏ธ Stale-while-revalidate: automatic reload when new content is available
  • โœจ Static assets handling: configure static assets for offline support
  • ๐Ÿž Development Support: debug your custom service worker logic as you develop your application

๐Ÿ“ฆ Install

npm i vite-plugin-pwa -D 

# yarn 
yarn add vite-plugin-pwa -D

# pnpm 
pnpm add vite-plugin-pwa -D

๐Ÿฆ„ Usage

๐ŸŽฉ From version 0.11.0, workbox has been updated to version 6.2.2 (previous versions were using 6.1.5 version): if you are using advanced configuration like workbox or injectManifest options, you must review the plugin configuration, since this new version of workbox has breaking changes!

๐ŸŽฉ Changes on version 0.12.0:

  • TypeScript updated to 4.6.3 version, client and DevOptions types changed to interface.
  • If you were using shortcuts on the PWA Manifest, there is a breaking change to add correct type for shortcuts icons, you should review all icon declarations.
  • You can change the PWA Manifest File name, which default value is manifest.webmanifest, use manifestFilename plugin option to change it.
  • workbox-build now loads on demand, if you are starting the development server and don't use DevOptions, workbox-build will not be loaded and the development server will boot faster.
  • You can now provide which Vite plugins add to the service worker build: we have added vite:json and commonjs, check defaultInjectManifestVitePlugins on src/constants.ts module. Beware using this option since you can break your project build.

Add VitePWA plugin to vite.config.js / vite.config.ts and configure it:

// vite.config.js / vite.config.ts
import { VitePWA } from 'vite-plugin-pwa'

export default {
  plugins: [
    VitePWA()
  ]
}

Read the ๐Ÿ“– documentation for a complete guide on how to configure and use this plugin.

Check out the client type declarations client.d.ts for built-in frameworks support.

๐Ÿ‘€ Full config

Check out the type declaration src/types.ts and the following links for more details.

๐Ÿ“„ License

MIT License ยฉ 2020-PRESENT Anthony Fu

vite-plugin-pwa's People

Contributors

719media avatar adrianrudnik avatar allanchain avatar andipaetzold avatar antfu avatar azamat-sharapov avatar buncolak avatar davedbase avatar dimitris-toulis avatar domsen123 avatar elmassimo avatar estebanfuentealba avatar f-loat avatar fishel-feng avatar floer32 avatar franciscohanna92 avatar hannoeru avatar holbrookdev avatar itsbiodude avatar jonaskuske avatar justinjc avatar lensanag avatar michaelhue avatar miguel-bento-github avatar nstringham avatar posva avatar taigabrew avatar userquin avatar v-ed avatar wtchnm avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.