# farm-plugin-pwa

> A pwa rust plugin for farm

Latest version **0.2.1** (published 2024-08-29) · MIT license · 0 weekly downloads

## Install

```sh
npm install farm-plugin-pwa
pnpm add farm-plugin-pwa
yarn add farm-plugin-pwa
bun add farm-plugin-pwa
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.1 |
| Published | 2024-08-29 |
| First published | 2024-06-19 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 8.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | weeken |
| Keywords | farm, farm plugin, farm-plugin, farm-plugin-pwa, rust plugin, pwa |

## Links

- npm: https://www.npmjs.com/package/farm-plugin-pwa
- Homepage: https://github.com/Weeken/farm-plugin-pwa
- npm.io page: https://npm.io/package/farm-plugin-pwa

## Recent versions

- 0.2.1 (latest) — 2024-08-29
- 0.2.0 — 2024-08-01
- 0.1.5 — 2024-07-26
- 0.1.4 — 2024-07-26
- 0.1.3 — 2024-07-19
- 0.1.2 — 2024-07-19
- 0.1.1 — 2024-07-16
- 0.1.0 — 2024-07-16
- 0.0.2 — 2024-07-12
- 0.0.1 — 2024-06-19

## README

## farm-plugin-pwa

A pwa rust plugin for farm

### Install

```bash
pnpm add -D farm-plugin-pwa
```

> [!NOTE]
> "@farmfe/core": "^1.2.0" --> "farm-plugin-pwa": "0.0.2"  
> "@farmfe/core": "^1.3.0" --> "farm-plugin-pwa": "^0.1.x"

### Usage

```ts
import { defineConfig } from "@farmfe/core";
import pwa from "farm-plugin-pwa";

interface Options {
  /* Your options here */
  /**
   * scope of sw cache
   */
  scope?: string; // default: publicPath of the farm config
  /**
   * name of the sw.js
   */
  sw_name?: string; // default: 'sw'
  /**
   * name of sw cache
   */
  cache_name?: string; // default: 'sw-cache'
  /**
   * custom cache files
   */
  static_files?: string[]; // ['/favicon.ico']
  /**
   * request url reg
   */
  patten?: string; // default:  /(.html|.js|.mjs|.css|.png|.jpg|.jpeg|.svg|.webp|.svga)$/
  /**
   * Web app manifests
   * see https://developer.mozilla.org/en-US/docs/Web/Manifest
   */
  manifest?: Record<string, any>;
}

export default defineConfig({
  plugins: [
    [
      "farm-plugin-pwa",
      {
        cache_name: `/front/pwa/`,
        sw_name: "pwa-sw",
      },
    ],
    // or
    pwa({
      cache_name: `/front/pwa/`,
      sw_name: "pwa-sw",
      static_files: [
        "/front/pwa/favicon.ico",
        "/front/pwa/robots.txt",
        "/front/pwa/safari-pinned-tab.svg",
      ],
      manifest: {
        id: "Test_PWA",
        name: "Test_PWA",
        short_name: "Test_PWA",
        theme_color: "#ffffff",
        background_color: "#ffffff",
        start_url: "/front/pwa/",
        scope: "/front/pwa/",
        display: "standalone",
        display_override: ["fullscreen", "minimal-ui"],
        icons: [
          {
            src: "/front/pwa/pwa-192x192.png",
            sizes: "192x192",
            type: "image/png",
          },
          {
            src: "/front/pwa/pwa-512x512.png",
            sizes: "512x512",
            type: "image/png",
          },
          {
            src: "/front/pwa/pwa-512x512.png",
            sizes: "512x512",
            type: "image/png",
            purpose: "any maskable",
          },
        ],
      },
    }),
  ],
});
```

---
_Source: https://npm.io/package/farm-plugin-pwa · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
