simple-pwa
v0.1.0
Published
Helper to serve PWA using express.js
Downloads
54
Readme
📦 Simple PWA
Example
import { createPWA } from 'simple-pwa';
import express from 'express';
import { pathToFileURL } from 'node:url';
const pwa = await createPWA({
// Creates an importmap. Set to 'bundle' to bundle into one file.
method: 'importmap',
// Base path. Defaults to CWD.
// Warning: make sure it's a path to a directory!
basePath: pathToFileURL(process.cwd() + '/ui/'),
// Entrypoint to be loaded relative to basePath
entrypoint: 'index.mjs',
// ... or the entrypoint might be created on-the-fly:
entrypointFactory: async () => `alert("Hello world");`,
// Directories to serve relative to basePath
staticDirs: ['assets'],
// Title of the Page
title: 'My super PWA',
// Charset. Defaults to 'utf-8'
charset: 'utf-8',
});
const app = express();
app.use(pwa);
app.listen(8080);