Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/Weeken/farm-plugin-pwa
A pwa rust plugin for farm
https://github.com/Weeken/farm-plugin-pwa
Last synced: about 2 months ago
JSON representation
A pwa rust plugin for farm
- Host: GitHub
- URL: https://github.com/Weeken/farm-plugin-pwa
- Owner: Weeken
- Created: 2024-06-18T10:06:45.000Z (7 months ago)
- Default Branch: main
- Last Pushed: 2024-08-29T06:50:01.000Z (4 months ago)
- Last Synced: 2024-11-02T05:39:04.803Z (2 months ago)
- Language: Rust
- Size: 1.33 MB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-farm - `farm-plugin-pwa`
- awesome-farm - `farm-plugin-pwa`
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;
}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",
},
],
},
}),
],
});
```